主题:大大们看看有没错。。
最简单的用 if 来选出最大的数字
# include <iostream>
using namespace std;
int main ()
{
int num1, num2, num3;
cout<< "Please enter three numbers : " ;
cin>> num1;
cin>> num2;
cin>> num3;
if(num1 > num2 && num1 > num3)
{
cout<< "The largest number is:" <<num1 <<endl;
}
else
{
if(num2 > num1 && num2 > num3)
{
cout<< " The largest number is:" <<num2 <<endl;
}
else
{
if (num3 > num1 && num3 > num2)
{
cout<< " The largest numberis:" <<num3 <<endl;
}
}
return 0;
}
# include <iostream>
using namespace std;
int main ()
{
int num1, num2, num3;
cout<< "Please enter three numbers : " ;
cin>> num1;
cin>> num2;
cin>> num3;
if(num1 > num2 && num1 > num3)
{
cout<< "The largest number is:" <<num1 <<endl;
}
else
{
if(num2 > num1 && num2 > num3)
{
cout<< " The largest number is:" <<num2 <<endl;
}
else
{
if (num3 > num1 && num3 > num2)
{
cout<< " The largest numberis:" <<num3 <<endl;
}
}
return 0;
}