5 条题解

  • 3
    @ 2023-3-19 18:06:15
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n;
        cin >> n;
        int a = n % 10;
        int b = n / 10 % 10;
        int c = n / 100;
        cout << max(c,max(a , b)) - min(c , min(a , b));
        return 0;
    }
    
    • 2
      @ 2022-11-27 16:18:13
      #include <bits/stdc++.h>
      using namespace std;
      int main()
      {
          int n, min = 999999, max = 0;
          cin >> n;
          while (n > 0)
          {
              if (n % 10 < min)
              {
                  min = n % 10;
              }
              if (n % 10 > max)
              {
                  max = n % 10;
              }
              n /= 10;
          }
          cout << max - min;
          return 0;
      }
      
      • @ 2023-2-20 20:15:00

        附极简AC代码

        #include <iostream>
        using namespace std;
        int main()
        {
            cout << '6';
            return 0;
        }
        
      • @ 2023-4-6 22:01:32

        @ 但凡两个样例

      • @ 2023-8-6 15:38:38

        就不行了

    • 1
      @ 2023-4-6 22:01:08
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
          int x;
          cin>>x;
          cout<<max(max(x/100,x/10%10),x%10)-min(min(x/100,x/10%10),x%10);
          return 0;
      }
      • 0
        @ 2023-10-13 0:04:17

        用字符串写一个

        #include<bits/stdc++.h>
        using namespace std;
        string s;
        int a[15];
        int main()
        {
            cin>>s;
            for(int i=0;i<3;i++)
            {
                a[i]=s[i];
            }
            sort(a,a+3);
            cout<<a[2]-a[0];
            return 0;
        }
        
        • 0
          @ 2023-9-24 9:20:28
          #include<bits/stdc++.h>
          using namespace std;
          int main()
          {
              int c,v,n,s;
              cin >> s;
              c = s % 10;
              v = s / 10 % 10;
              n = s /100;
              int a = max(c,max(v,n));
              int b = min(c,max(v,n));
              cout <<a - b;
              return 0;
          }//A
          
          • 1

          【入门】最大数和最小数的差

          信息

          ID
          664
          时间
          1000ms
          内存
          16MiB
          难度
          1
          标签
          递交数
          74
          已通过
          57
          上传者