Advertisement
ValerianBenchea

+++PalMunte

Jan 23rd, 2020
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int a, b, max1=0, max2=0, min1=9, min2=9, c;
  8.     cout<<"a="; cin>>a;
  9.     cout<<"b="; cin>>b;
  10.     while(a!=0)
  11.     {
  12.         c=a%10;
  13.         if(c>max1)
  14.             max1=c;
  15.         if(c<min1)
  16.             min1=c;
  17.         a/=10;
  18.     }
  19.     while(b!=0)
  20.     {
  21.         c=b%10;
  22.         if(c>max2)
  23.             max2=c;
  24.         if(c<min2)
  25.             min2=c;
  26.         b/=10;
  27.     }
  28.     if(min1>min2)
  29.         cout<<min2<<min1<<" ";
  30.     else
  31.         cout<<min1<<min2<<" ";
  32.     if(max1>max2)
  33.         cout<<max1<<max2<<" ";
  34.     else
  35.         cout<<max2<<max1<<" ";
  36.         return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement