5 条题解

  • 1
    @ 2026-1-28 12:40:39

    好吧,这回重新发一遍,上次可能因为带有一丝挑衅的意思所以有俩差评。

    这道题其实没必要太复杂,又是a>b的又是c>b的,没必要。那该怎么做呢,其实用max函数就行了,想一下既然max函数能让两个数比大小那为什么不能让三个数比大小呢(max(a,max(b,c))) 代码如下:

    #include <bits/stdc++.h>//因为要用max所以不能用iostream
    using namespace std;
    int main()
    {
    	int a,b,c;
    	cin>>a>>b>>c;
    	cout<<max(a,max(b,c));
    }
    
    • 0
      @ 2025-2-20 15:54:34

      #include #include using namespace std; int main() { int a,b,c; cin>>a>>b>>c; if(a>=b&&a>=c) { cout<<a; } else if(b>=a&&b>=c) { cout<<b; } else if(c>=a&&c>=a) { cout<<c; } return 0; }

      • -1
        @ 2025-7-19 22:30:48

        不知道作者怎么想的,为什么会出这么简单的题 题目很简单,就是三个数求最值,这里介绍一个交换变量的值的函数swap:swap(a,b)=交换a,b的值

        下面奉上一份c++代码:

        
        /*
        1.输入a,b,c
        2.如果a比b小,交换a,b的值 //此时b存放的就是小的数
        3.如果b比c小,交换b,c的值 //此时c存放的就是小的数
        4.再次比较a和b的大小,如果a比b小,交换a,b的值
        */
        #include <bits/stdc++.h>
        using namespace std;
        int a,b,c;
        int main()
        {
            cin>>a>>b>>c;
            if(a<b){
                swap(a,b);
            }
            if(b<c){
                swap(b,c);
            }
            if(a<b){
                swap(a,b);
            }
            cout<<a;
            return 0;
        }
        
        • -2
          @ 2024-12-26 22:45:12

          #include<bits/stdc++.h> using namespace std; int main(){ int a,b,c,max; cin>>a>>b>>c; if(a>b){ max=a; } else{ max=b; } if(c>max){ max=c; } cout<<max; return 0; }

          • -2
            @ 2024-12-26 22:44:53

            #include<bits/stdc++.h> using namespace std; int main(){ int a,b,c,max; cin>>a>>b>>c; if(a>b){ max=a; } else{ max=b; } if(c>max){ max=c; } cout<<max; return 0; }

            • 1

            信息

            ID
            115
            时间
            1000ms
            内存
            256MiB
            难度
            1
            标签
            (无)
            递交数
            215
            已通过
            76
            上传者