fork download
  1. #include<iostream>
  2. using namespace std;
  3. int main(){
  4.  
  5. int N; cin>>N;
  6.  
  7. int Digit; cin>>Digit;
  8.  
  9. int x;
  10. int Sum = 0;
  11. while(Digit != 0){
  12.  
  13. x = Digit % 10;
  14.  
  15. Sum = Sum + x;
  16.  
  17. Digit = Digit / 10;
  18. }
  19.  
  20. cout<<Sum;
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
24