C++中如何用switch判断两个数的大小?
来源:百度知道 编辑:UC知道 时间:2024/06/07 03:34:30
C++中如何用switch判断两个数的大小?
比如用大于符号,用一个变量保留a>b的真假值,再用switch进行判断就可以了。
boolean max;
int a,b;
cout<<"Please input a"<<endl;
cin>>a;
cout<<"Please input b"<<endl;
cin>>b;
s=(a>b)
switch (s)
case true:
cout<<"a>b"
break;
default:
cout<<"a<=b"
break;