fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int sum =0;
  7. char next = '0';
  8. do{
  9. sum += next-'0';
  10. cin>>next;
  11. }while(next!='0');
  12. cout<<sum<<endl;
  13. return 0;
  14. }
Success #stdin #stdout 0s 3100KB
stdin
5430
stdout
12