马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 英俊男孩建坤 于 2021-2-2 02:17 编辑 #include<iostream>
using namespace std;
int main(){
int a ,b ,c,sum;
cout <<"Enter three different integers:";
cin >> a>> b>> c;
sum = a+ b+ c;
cout << "Sum is: "<< sum<< endl;
cout <<"Average is: "<< sum /3<< endl;
cout <<"Product is: "<< a*b*c<< endl;
if (a>b>c){
cout <<"The largest number is: "<< a<< endl;
cout <<"The smallest number is: "<< c<< endl;
}else if (a>c>b){
cout <<"The largest number is: "<< a<< endl;
cout <<"The smallest number is: "<< b<< endl;
}else if (b>a>c){
cout <<"The largest number is: "<< b<< endl;
cout <<"The smallest number is: "<< c<< endl;
}else if (b>c>a){
cout <<"The largest number is: "<< b<< endl;
cout <<"The smallest number is: "<< a<< endl;
}else if(c>a>b){
cout <<"The largest number is: "<< c<< endl;
cout <<"The smallest number is: "<< b<< endl;
}else{
cout <<"The largest number is: "<< c<< endl;
cout <<"The smallest number is: "<< a<< endl;
}
return 0;
}
为什么最后比较三个数字的大小部分不能正常运行 我无论如何输入数字就只会执行最后的else部分语句 并不会进行比较
|