@vlad from moscow: I don't see why that makes it invalid. It was supposed to return the biggest element, and there is no one.
@OP: you may use an array to store the numbers and then just std::max_element( begin(array), end(array) );
However If there are several with the max value it will output the first one.
No output - is it an answer?! If you ask somebody question and that somebody has said nothing you will think that you have gotten the answer?! And what about if that somebody is simply deaf?!
In my opinion absense of a message confuses the user because he does not know whether the program executed successfully or it did something wrong. It is a situation of uncertainty.
Btw, borges-my-world-is-unix would much rather have programs (or for that matter people) who have nothing to say, to actually say nothing. Not shout 'Now listen to me carefully: I have nothing to say'
In my opinion, I think skarla (44) 's program is asking users to input three int numbers and then output the biggest one of them, am I right ?
so you wanna ask if there is a better way to get the biggest one , how to optimize the program, maybe you can use (x>y?x:y) to optimize it.
/*********************************
题目:输入三个整数,然后求出最大的那个并且输出它的值,
输入:三个整型数字;
输出:三个整数中最大的一个;
**********************************/
#include <iostream>
usingnamespace std;
void main()
{
//变量定义
int a,b,c;
//输出要用户输入的信息
cout<<"Give the 3 numbers separated with space :"<<endl;
cin>>a>>b>>c;
cout<<endl;
int m = ( c >= (a >= b ? a : b) ? c : ( a >= b ? a : b ) );
cout<<"the biggest one is :"<<m<<endl;
system("pause");
}
this is my first reply ,if i do something wrong please forgive me.