Last active
March 26, 2019 18:53
-
-
Save invatainfo/a99cce39e98567d9c83b9339f527f695 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
void inserare(int& n) | |
{ | |
int new_n = 0, last_digit, p = 1; | |
while (n >= 10) { | |
new_n += (n % 10) * p; | |
p *= 10; | |
new_n += abs(n % 10 - (n / 10) % 10) * p; | |
n = n / 10; | |
p *= 10; | |
} | |
new_n += (n % 10) * p; | |
n = new_n; | |
} | |
int main() { | |
int n; | |
cin >> n; | |
inserare(n); | |
cout << n << endl; | |
return 0; | |
} | |
~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment