kolioi

Substitute C++

Sep 9th, 2018
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int K, L, M, N;
  6.     cin >> K >> L >> M >> N;
  7.  
  8.     if (K % 2 == 1)
  9.         K++;
  10.  
  11.     if (M % 2 == 1)
  12.         M++;
  13.  
  14.     if (L % 2 == 0)
  15.         L++;
  16.  
  17.     if (N % 2 == 0)
  18.         N++;
  19.  
  20.     int substitutes = 0;
  21.  
  22.     for (int k = K; k <= 8 && substitutes < 6; k += 2)      // [K,8]
  23.     {
  24.         for (int l = 9; l >= L && substitutes < 6; l -= 2)      // [9,L]
  25.         {
  26.             for (int m = M; m <= 8 && substitutes < 6; m += 2)      // [M,8]
  27.             {
  28.                 for (int n = 9; n >= N && substitutes < 6; n -= 2)      // [9,N]
  29.                 {
  30.                     if (k == m && l == n)
  31.                         cout << "Cannot change the same player.\n";
  32.                     else
  33.                     {
  34.                         cout << k << l << " - " << m << n << endl;
  35.                         substitutes++;
  36.                     }
  37.                 }
  38.             }
  39.         }
  40.     }
  41.  
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment