8 条题解

  • 1

    思路

    因为是四位数,位数确定,所以可以用 char 来写。

    code

    #include<bits/stdc++.h>
    using namespace std;
    char a,b,c,d;
    int main(){
      cin>>a>>b>>c>>d;
      cout<<a-'0'+b-'0'+c-'0'+d-'0';
      return 0;
    }
    
    • 1
      @ 2023-12-24 13:24:45

      #include<bits/stdc++.h> using namespace std; int main(){ int a,b,c,d,e,f; cin>>a; b=a/1000; c=a/100%10; d=a/10%10; e=a%10; f=b+c+d+e; cout<<f; return 0; }

      • 0
        @ 2024-11-7 13:30:40

        #include<bits/stdc++.h> using namespace std; int main() { int a,b,c,d,n; cin>>n; a=n/100/10; b=n/100%10; c=n%100/10; d=n%10; cout<<a+b+c+d; return 0; }

        • 0
          @ 2024-11-6 13:04:05

          #include<bits/stdc++.h> using namespace std; int main() { int a,b,c,d,e,f; cin>>a; b=a/1000; c=a/100%10; d=a/10%10; e=a%10; f=b+d+c+e; cout<<fixed<<setprecision(0)<<f; return 0; }

          • 0
            @ 2024-1-28 11:45:29

            拿char多好做

            #include<bits/stdc++.h>
            using namespace std;
            int main()
            {
             char a,b,c,d;
             cin>>a>>b>>c>>d;
            int sd=a+b+c+d-4*48;
            cout<<sd;
            return 0;
            }
            
            • 0
              @ 2023-12-27 13:54:14

              #include<bits/stdc++.h> using namespace std; int main() { int a,b,c,d,e,f; cin>>a; b=a/1000; c=a/100%10; d=a/10%10; e=a%10; f=b+c+d+e; cout<<f; return 0; }

              • -1
                @ 2023-12-24 16:52:02

                #include<bits/stdc++.h> using namespace std; int main() { int a,b,c,d,e,f; cin>>a; b=a/1000; c=a/100%10; d=a/10%10; e=a%10; f=b+c+d+e; cout<<f; return 0; }image

                • -1
                  @ 2023-12-23 13:49:27

                  #include<iostream> using namespace std; int main() { int a,b,c,d,e,f; cin>>a; b=a/1000; c=a/100%10; d=a/10%10; e=a%10; f=b+c+d+e; cout<<f; return 0; }

                  • 1

                  信息

                  ID
                  14
                  时间
                  1000ms
                  内存
                  256MiB
                  难度
                  1
                  标签
                  递交数
                  193
                  已通过
                  128
                  上传者