3 条题解

  • 3
    @ 2022-12-24 11:21:41
    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n;
        cin >> n;
        int x = n, c = n, num = 0, sum = 0;
        while (x > 0)
        {
            if (x % 10 == 5)
            {
                sum++;
                break;
            }
            x /= 10;
        }
        if (sum == 1)
        {
            while (c > 0)
            {
                num += c % 10;
                c /= 10;
            }
            cout << num;
        }
        else
        {
            cout << n;
        }
        return 0;
    }
    
    • 1
      @ 2023-3-19 17:53:37

      最简代码,已AC放心食用

      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
          int n;
          cin >> n;
          if(n % 10 == 5 || n / 10 % 10 == 5 || n / 100 % 10 == 5 || n / 1000 % 10 == 5 || n / 10000 == 5)
          {
              cout << n % 10  + n / 10 % 10  + n / 100 % 10  + n / 1000 % 10 + n / 10000;
          }
          else
          {
              cout << n;
          }
          return 0;
      }
      
      • 0
        @ 2023-4-6 21:47:14
        #include<bits/stdc++.h>
        using namespace std;
        int main()
        {
            int x;
            cin>>x;
            if (x/10000==5||x/1000%10==5||x/100%10==5||x/10%10==5||x%10==5)
                cout<<x/10000+x/1000%10+x/100%10+x/10%10+x%10;
            else
                cout<<x;
            return 0;
        }
        • 1

        信息

        ID
        656
        时间
        1000ms
        内存
        16MiB
        难度
        1
        标签
        递交数
        95
        已通过
        67
        上传者