RuslanMag

Шахматы_new

Nov 18th, 2019
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. const int n = 7;
  6.  
  7. int arr[n][n] =
  8. {
  9.     {0, 1, 0, 1, 0, 1, 0},
  10.     {1, 0, 1, 0, 1, 0, 1},
  11.     {0, 1, 0, 1, 0, 1, 0},
  12.     {1, 0, 1, 0, 1, 0, 1},
  13.     {0, 1, 0, 1, 0, 1, 0},
  14.     {1, 0, 1, 0, 1, 0, 1},
  15.     {0, 1, 0, 1, 0, 1, 0}
  16. };
  17.  
  18. bool ok = true;
  19.  
  20. int main() {
  21.  
  22.     for (int i = 0; i < n; i++)
  23.     {
  24.         for (int j = 0; j < n; j++)
  25.         {
  26.             cout << setw(4) << arr[i][j];
  27.         }
  28.         cout << endl;
  29.     }
  30.  
  31.     for (int i = n - 1; i > 0; i--)
  32.     {
  33.         for (int j = 1; j < n; j++)
  34.         {
  35.             if (arr[i - 1][j] == arr[i][j] || arr[i][j - 1] == arr[i][j])
  36.             {
  37.                 ok = false;
  38.                 break;
  39.             }
  40.             if (arr[0][j - 1] == arr[0][j])
  41.             {
  42.                 ok = false;
  43.                 break;
  44.             }
  45.         }
  46.     }
  47.  
  48.     if (ok)
  49.     {
  50.         cout << endl << "yes";
  51.     }
  52.     else
  53.     {
  54.         cout << endl << "no";
  55.     }
  56.     return 0;
  57. }
Add Comment
Please, Sign In to add comment