3 solutions

  • 0
    @ 2023-3-12 11:20:56
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    	int a;
        cin>>a;
        int s=a%10+a/10%10+a/100;
        cout<<s;
    	return 0;
    }
    
    • -1
      @ 2025-10-29 22:12:06
      #include <bits/stdc++.h>
      using namespace std;
      #define LL long long
      const int N=1e6+10;
      string s;
      int main(){
      	ios::sync_with_stdio(false);
      	cin.tie(0);cout.tie(0);
      	cin>>s;
      	int ans=0;
      	for(auto x:s) ans+=x-'0';
      	cout<<ans;
      	return 0;
      }
      
      • -2
        @ 2023-4-1 21:49:08
        n = int(input(""))
        a = n // 100
        b = n % 100 // 10  
        c = n % 10  
        print(a+b+c)
        
        • 1

        Information

        ID
        19
        Time
        1000ms
        Memory
        256MiB
        Difficulty
        1
        Tags
        (None)
        # Submissions
        332
        Accepted
        258
        Uploaded By