Advertisement
icatalin

Problema 9 tema suplimentara

Nov 28th, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int S=0,n,cif;
  8. cout<<"n="<<endl;
  9. cin>>n;
  10. while (n)
  11. {
  12. cif=n%10;
  13. S=S+cif;
  14. if (S>=10)
  15. S=S%10+S/10;
  16. n=n/10;
  17. }
  18. cout<<S;
  19. return 0;
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement