Răspuns :
#include <iostream>
using namespace std;
int main()
{
int n, inv, n1, n2, cif;
cin >> n;
while(n != 0)
{
inv = inv * 10 + n % 10;
n = n / 10;
}
while(inv != 0)
{
cif = inv % 10;
if(cif % 2 == 0) n1 = n1 * 10 + cif;
else n2 = n2 * 10 + cif;
inv = inv / 10;
}
if(n1 >= n2) cout << n1 - n2;
else cout << n2 - n1;
return 0;
}
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int n,p,n1=0,n2=0,x,d;
cin>>n;
x=n;
while (n!=0)
{
p=1;
if(n%2==0)
{
n1=n1+ p*(n%10);
p=p*10;
}
n=n/10;
}
p=1;
while(x!=0)
{
if(x%2!=0)
{
n2=n2+ p*(x%10);
p=p*10;
}
x=x/10;
}
d=abs(n1-n2);
cout<<d;
return 0;
}