fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void solve() {
  6. long long n;
  7. cin >> n;
  8.  
  9. long long sum = 0;
  10. while (n > 0) {
  11. sum += n % 10;
  12. n /= 10;
  13. }
  14.  
  15. cout << sum << "\n";
  16. }
  17.  
  18. int main() {
  19. ios_base::sync_with_stdio(false);
  20. cin.tie(NULL);
  21.  
  22. int t;
  23. if (cin >> t) {
  24. while (t--) {
  25. solve();
  26. }
  27. }
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
Standard output is empty