求最简单的两数比大小的算法
RT,题目的要求是不用中间变量,只比较一次,然后按照:
the smaller is :...
the larger is :..
进行输出。
求最简单的算法,整数浮点数都可以比较
C或者C++都可以,最好C++
求大牛赐教
[解决办法]
只比较一次可以这样
#include<iostream>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
a<b?(cout<<"the smaller is :"<<a<<endl<<"the larger is "<<b):(cout<<"small is"<<b<<endl<<"bigger is "<<a);
system("pause");
return 0;
}