Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int suma(int n)
  5. {
  6. int s = 0;
  7. while(n)
  8. {
  9. s = s + n % 10;
  10. n/=10;
  11. }
  12. return s;
  13. }
  14.  
  15. int main()
  16. {
  17. int n;
  18. cin >> n;
  19. int s= suma(n);
  20. int cnt = s;
  21. while(s >= 9)
  22. cout << 9, s -= 9, cnt --;
  23.  
  24. cout << s, cnt --;
  25.  
  26. while(cnt)
  27. cout << 0, cnt--;
  28.  
  29.  
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement