Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int S=0,n,cif;
- cout<<"n="<<endl;
- cin>>n;
- while (n)
- {
- cif=n%10;
- S=S+cif;
- if (S>=10)
- S=S%10+S/10;
- n=n/10;
- }
- cout<<S;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement