Created
September 4, 2019 18:33
-
-
Save invatainfo/7ce8a36b194f361f995b929cd8429f51 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 Impare(int &n) { | |
int new_n, p = 1; | |
while (n > 0) { | |
int new_digit = n % 10; | |
if (n % 2 == 1) { | |
new_digit--; | |
} | |
new_n = new_digit * p + new_n; | |
p = p * 10; | |
n = n / 10; | |
} | |
n = new_n; | |
} | |
int main() { | |
int n; | |
cin >> n; | |
Impare(n); | |
cout << n << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment