Advertisement
STANAANDREY

suma permutari

Sep 18th, 2019
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include "bits/stdc++.h"
  2. using namespace std;
  3.  
  4. int n, s, cif;
  5.  
  6. void solve(int cn)
  7. {
  8.     s += cn;
  9.     int u = cn % 10;
  10.     cn /= 10;
  11.     u *= (int)pow(10, cif - 1) + 1;
  12.     cn = u + cn;
  13.     if (cn == n)
  14.         return;
  15.     solve(cn);
  16. }
  17.  
  18. int main()
  19. {
  20.     cin >> n;
  21.     int cn = n;
  22.     do
  23.     {
  24.         cn /= 10;
  25.         cif++;
  26.     } while (cn);
  27.     solve(n);
  28.     cout << s;
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement