Advertisement
ioana_martin98

Untitled

Jun 9th, 2021
1,096
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     unsigned int x, k = 0, c;
  7.     int y, z;
  8.     cin >> x;
  9.     z = 0; y = 0;
  10.     while (x != 0)
  11.     {
  12.         c = x % 10;
  13.         if (c == 9)
  14.         {
  15.             y = -1;
  16.             break;
  17.         }
  18.         z = z * 10 + c + 1;
  19.         k++;
  20.         x = x / 10;
  21.     }
  22.     if (y != -1)
  23.         while (z != 0)
  24.         {
  25.             y = y * 10 + z % 10;
  26.             z = z / 10;
  27.         }
  28.  
  29.     cout << y;
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement