Advertisement
RadioNurshat

Reverse Number

Sep 27th, 2020
1,305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.24 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int n;
  6.     cin >> n;
  7.     if (n < 0) n = -n;
  8.     int result = 0;
  9.     while (n > 0) {
  10.         result = result * 10 + n % 10;
  11.         n = n / 10;
  12.     }
  13.     cout << result;
  14. }
  15.  
  16.  
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement