T3000

Untitled

Jan 27th, 2022
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.27 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. using ll = long long;
  5.  
  6. int main()
  7. {
  8.     vector<ll> z1;
  9.     ll t = 5;
  10.     while (t-- > 0)
  11.     {
  12.         ll a;
  13.         cin >> a;
  14.         z1.push_back(a);
  15.     }
  16.  
  17.     while (z1.at(0) != 1 || z1.at(1) != 2 || z1.at(2) != 3 || z1.at(3) != 4 || z1.at(4) != 5)
  18.     {
  19.  
  20.         if (z1.at(0) > z1.at(1))
  21.         {
  22.             swap(z1.at(0), z1.at(1));
  23.  
  24.             for (int i = 0; i < 5; i++)
  25.             {
  26.                 cout << z1.at(i) << " ";
  27.             }
  28.             cout << '\n';
  29.         }
  30.         if (z1.at(1) > z1.at(2))
  31.         {
  32.             swap(z1.at(1), z1.at(2));
  33.  
  34.             for (int i = 0; i < 5; i++)
  35.             {
  36.                 cout << z1.at(i) << " ";
  37.             }
  38.             cout << '\n';
  39.         }
  40.         if (z1.at(2) > z1.at(3))
  41.         {
  42.             swap(z1.at(2), z1.at(3));
  43.  
  44.             for (int i = 0; i < 5; i++)
  45.             {
  46.                 cout << z1.at(i) << " ";
  47.             }
  48.             cout << '\n';
  49.         }
  50.         if (z1.at(3) > z1.at(4))
  51.         {
  52.             swap(z1.at(3), z1.at(4));
  53.  
  54.             for (int i = 0; i < 5; i++)
  55.             {
  56.                 cout << z1.at(i) << " ";
  57.             }
  58.             cout << '\n';
  59.         }
  60.     }
  61.  
  62.     return 0;
  63.  
Advertisement
Add Comment
Please, Sign In to add comment