Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <conio.h>
- #include <stdio.h>
- #include <iostream>
- #include <math.h>
- #include <algorithm>
- using namespace std;
- #define PAR (!((numar % 10) % 2))
- #define IMPAR (((numar % 10) % 2))
- int ParImpar(bool par,int numar) {
- int finalPar = 0, produs = 1;
- while (numar) {
- if (par ? PAR : IMPAR) {
- finalPar = finalPar + numar % 10 * produs;
- produs *= 10;
- numar /= 10;
- }
- else {
- numar /= 10;
- }
- }
- return finalPar;
- }
- void main() {
- int numar1, numar2,rez1,rez2;
- cin >> numar1;
- rez1 = (numar1 % 2 == 0 ) ? ParImpar(true, numar1) : ParImpar(false, numar1);
- cin >> numar2;
- rez2 = (numar2 % 2 == 0) ? ParImpar(true, numar2) : ParImpar(false, numar2);
- cout << ((rez1 == rez2) ? ((numar1 > numar2) ? numar1 : numar2) : (rez1 > rez2) ? numar1 : numar2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement