Advertisement
thedigletdistroyer

Untitled

Feb 5th, 2023
737
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int n,aux,s=0,p=0,k=0;
  6.     cin>>n;
  7.     while(n!=0)
  8.     {
  9.         s=s+n%10;
  10.         n/=10;
  11.     }
  12.     aux=s;
  13.     while(s>9)
  14.     {
  15.         cout<<"9";
  16.         k++;
  17.         s=s-9;
  18.     }
  19.     cout<<s;
  20.     while(p<aux-k-1)
  21.     {
  22.         cout<<"0";
  23.         p++;
  24.     }
  25.  
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement