Răspuns:
#include <iostream>
using namespace std;
int m,n,a,b,c,e,f,g,M1,M2,m1,m2;
int main()
{
cin>>m>>n;
a=m/100;
b=m/10%10;
c=m%10;
e=n/100;
f=n/10%10;
g=n%10;
M1=max(max(a,b),c);
M2=max(max(e,f),g);
m1=min(min(a,b),c);
m2=min(min(e,f),g);
cout<<max(M1,M2)*10+min(M1,M2)<<" ";
/*if(n%100==0 and m%100==0)
cout<<min(M1,M2)*10+max(M1,M2);
else*/
{
m1=min(min(a*10+e,e*10+a), min(a*10+f,a*10+g));
m1=min(m1,min(e*10+b,e*10+c));
if(b*10+e>9)
m1=min(m1,b*10+e);
if(b*10+f>9)
m1=min(m1,b*10+f);
if(b*10+g>9)
m1=min(m1,b*10+g);
if(c*10+e>9)
m1=min(m1,c*10+e);
if(c*10+f>9)
m1=min(m1,c*10+f);
if(c*10+g>9)
m1=min(m1,c*10+g);
if(f*10+a>9)
m1=min(m1,f*10+a);
if(f*10+b>9)
m1=min(m1,f*10+b);
if(f*10+c>9)
m1=min(m1,f*10+c);
if(g*10+a>9)
m1=min(m1,g*10+a);
if(g*10+b>9)
m1=min(m1,g*10+b);
if(g*10+c>9)
m1=min(m1,g*10+c);
cout<<m1;
}
return 0;
}