Advertisement
Ola_Imiolczyk

S2 Zad 8

Nov 14th, 2020
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1.  
  2. int main()
  3. {
  4.     /*8.Napisz program pobierający od użytkownika 3 liczby
  5.        i drukujący na ekranie te liczby w kolejności niemalejącej. */
  6.  
  7. int x,y,z;
  8.  
  9.     cout<<"Podaj 3 liczby"<<endl;
  10.  
  11.     cout<<"Podaj liczbe x:"<<endl;
  12.     cin>>x;
  13.  
  14.     cout<<"Podaj liczbe y:"<<endl;
  15.     cin>>y;
  16.  
  17.     cout<<"Podaj liczbe z:"<<endl;
  18.     cin>>z;
  19.  
  20.     if(x<y&&x<z) // x jest najmniejsze
  21.     {
  22.         if(y<z)
  23.         {
  24.             cout<<x<<" "<<y<<" "<<z;
  25.         }
  26.         else
  27.         {
  28.             cout<<x<<" "<<z<<" "<<y;
  29.         }
  30.     }
  31.     else if (y<x&&y<z) // y jest najmniejsze
  32.     {
  33.         if(x<z)
  34.         {
  35.             cout<<y<<" "<<x<<" "<<z;
  36.         }
  37.         else
  38.         {
  39.             cout<<y<<" "<<z<<" "<<x;
  40.         }
  41.     }
  42.     else // z jest najmniejsze
  43.     {
  44.         if(x<y)
  45.         {
  46.             cout<<z<<" "<<x<<" "<<y;
  47.         }
  48.         else
  49.         {
  50.             cout<<z<<" "<<y<<" "<<x;
  51.         }
  52.     }
  53.  
  54.  
  55.     return 0;
  56. }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement