Răspuns :
Răspuns:
#include <iostream>
using namespace std;
int main()
{
int n1, n2, z1=1, z2=1, pi1=0, pi2=0, cif;
cin >> n1 >> n2;
int m1=n1, m2=n2;
while (m1>9)
{ m1/=10; z1*=10; }
while (m2>9)
{ m2/=10; z2*=10; }
if (n1%2)
{
m1=n1;
while (m1)
{
cif=m1/z1; m1%=z1; z1/=10;
if (cif%2) pi1=pi1*10+cif;
}
}
else
{
m1=n1;
while (m1)
{
cif=m1/z1; m1%=z1; z1/=10;
if (cif%2==0) pi1=pi1*10+cif;
}
}
if (n2%2)
{
m2=n2;
while (m2)
{
cif=m2/z2; m2%=z2; z2/=10;
if (cif%2) pi2=pi2*10+cif;
}
}
else
{
m2=n2;
while (m2)
{
cif=m2/z2; m2%=z2; z2/=10;
if (cif%2==0) pi2=pi2*10+cif;
}
}
if (pi1!=pi2)
{
if (pi1>pi2) cout << n1;
else cout << n2;
}
else
{
if (n1>n2) cout << n1;
else cout << n2;
}
return 0;
}
Explicație:
#include <iostream>
using namespace std;
int main()
{
int n,m,parimp1=0,parimp2=0,p=1,auxn,auxm;
cin>>n>>m;
auxn=n;
auxm=m;
if(n%2==0)
{
while(n)
{
if(n%2==0)
{
parimp1=(n%10)* p +parimp1;
p*=10;
}
n/=10;
}
}
else
{
while(n)
{
if(n%2!=0)
{
parimp1=(n%10)* p +parimp1;
p*=10;
}
n/=10;
}
}
p=1;
if(m%2==0)
{
while(m)
{
if(m%2==0)
{
parimp2=(m%10)* p +parimp2;
p*=10;
}
m/=10;
}
}
else
{
while(m)
{
if(m%2!=0)
{
parimp2=(m%10)* p +parimp2;
p*=10;
}
m/=10;
}
}
if(parimp1>parimp2)
{
cout<<auxn;
}
else if(parimp1<parimp2)
{
cout<<auxm;
}
else
{
if(auxn>auxm)
{
cout<<auxn;
}
else
{
cout<<auxm;
}
}
return 0;
}
e de 100 pct.