Advertisement
alaminrifat

URI -1042 with C++

Apr 24th, 2020
446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. void printOrder(int x, int y, int z);
  6. void print(int a, int b, int c);
  7.  
  8. int main()
  9. {
  10.     int x,y,z;
  11.     cin>>x>>y>>z;
  12.     printOrder(x,y,z);
  13.     print(x,y,z);
  14. }
  15.  
  16.  
  17. void printOrder(int x, int y, int z)
  18. {
  19.     int t1,t2,t3;
  20.     if(x<y && x<z)
  21.     {
  22.         t1 = x;
  23.         if(y<z)
  24.         {
  25.             t2=y;
  26.             t3=z;
  27.         }
  28.         else
  29.         {
  30.             t2=z;
  31.             t3=y;
  32.         }
  33.     }
  34.  
  35.     else if(y<x && y<z)
  36.     {
  37.         t1=y;
  38.         if(x<z)
  39.         {
  40.             t2=x;
  41.             t3=z;
  42.         }
  43.         else
  44.         {
  45.             t2=z;
  46.             t3=x;
  47.         }
  48.     }
  49.  
  50.     else
  51.     {
  52.         t1 =z;
  53.         if(x<y)
  54.         {
  55.             t2=x;
  56.             t3=y;
  57.         }
  58.         else
  59.         {
  60.             t2=y;
  61.             t3=x;
  62.         }
  63.  
  64.     }
  65.  
  66.  
  67.     cout << t1 << endl << t2 << endl << t3 << endl << endl;
  68. }
  69.  
  70.  
  71.  
  72.  
  73. void print(int x, int y, int z)
  74. {
  75.     cout << x << endl << y << endl << z << endl;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement