Skip to content

Instantly share code, notes, and snippets.

@invatainfo
Created September 4, 2019 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save invatainfo/7ce8a36b194f361f995b929cd8429f51 to your computer and use it in GitHub Desktop.
Save invatainfo/7ce8a36b194f361f995b929cd8429f51 to your computer and use it in GitHub Desktop.
#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