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