fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. long long n;
  6. cin >> n;
  7.  
  8. long long sum = 0;
  9.  
  10. while (n > 0) {
  11. sum += n % 10;
  12. n /= 10;
  13. }
  14.  
  15. cout << sum;
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 5316KB
stdin
1234567891234567891
stdout
91