英俊男孩建坤 发表于 2021-2-2 01:57:03

求大佬帮我看看

本帖最后由 英俊男孩建坤 于 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部分语句并不会进行比较

wp231957 发表于 2021-2-2 06:57:02

a>b>c这种语法有些想当然了,电脑不能识别

伪文青 发表于 2021-2-2 10:36:51

wp231957 发表于 2021-2-2 06:57
a>b>c这种语法有些想当然了,电脑不能识别

没错,没这样的语法的
页: [1]
查看完整版本: 求大佬帮我看看