fork download
  1. // Problem: A. A+B Again?
  2. // URL: https://c...content-available-to-author-only...s.com/problemset/problem/1999/A
  3. // Tag: Implementation, Math
  4.  
  5. #include <iostream>
  6. using namespace std;
  7.  
  8. int main() {
  9. int t;
  10. cin >> t;
  11.  
  12. while (t--)
  13. {
  14. string s;
  15. cin >> s;
  16.  
  17. int sum = 0;
  18. for (char c : s)
  19. {
  20. sum += c - '0';
  21. }
  22. cout << sum << endl;
  23.  
  24. }
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5260KB
stdin
8
77
21
40
34
19
84
10
99
stdout
14
3
4
7
10
12
1
18