fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4. ll tongcs(ll a)
  5. {
  6. if (a == 0)
  7. return 0;
  8. return a % 10 + tongcs(a / 10);
  9. }
  10. int main()
  11. {
  12. ll x;
  13. cin >> x;
  14. cout << tongcs(x);
  15. }
  16.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
60