fork download
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. // YOUR CODE GOES HERE
  7. // Please take input and print output to standard input/output (stdin/stdout)
  8. // E.g. 'cin' for input & 'cout' for output
  9.  
  10.  
  11. int input;
  12. cin >> input;
  13.  
  14.  
  15. while(input-- > 0)
  16. {
  17. int t;
  18. cin >> t;
  19. int sum = 0;
  20.  
  21. while(t > 0)
  22. {
  23. sum = sum + t%10;
  24. t = t/10;
  25. }
  26. cout << sum;
  27. }
  28.  
  29.  
  30.  
  31. return 0;
  32. }
Success #stdin #stdout 0.01s 5320KB
stdin
3
567
123
332
stdout
1868