- #include <iostream>
- using namespace std;
- int cifreImpare(int n) {
- int cifra, nou = 0, impare = 0,ok=0;
- while (n != 0) {
- cifra = n % 10;
- n /= 10;
- ok++;
- if (cifra % 2 == 0) {
- nou = nou * 10 + cifra;
- } else {
- impare++;
- }
- }
- if (impare == 0|| ok==impare) {
- return -1;
- } else {
- int invers = 0;
- while (nou != 0) {
- cifra = nou % 10;
- nou /= 10;
- invers = invers * 10 + cifra;
- }
- return invers;
- }
- }
- int main()
- {
- int n;
- cin>>n;
- cout << cifreImpare(n) << endl;
- return 0;
- }
Raw Paste