Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- const int n = 7;
- int arr[n][n] =
- {
- {0, 1, 0, 1, 0, 1, 0},
- {1, 0, 1, 0, 1, 0, 1},
- {0, 1, 0, 1, 0, 1, 0},
- {1, 0, 1, 0, 1, 0, 1},
- {0, 1, 0, 1, 0, 1, 0},
- {1, 0, 1, 0, 1, 0, 1},
- {0, 1, 0, 1, 0, 1, 0}
- };
- bool ok = true;
- int main() {
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < n; j++)
- {
- cout << setw(4) << arr[i][j];
- }
- cout << endl;
- }
- for (int i = n - 1; i > 0; i--)
- {
- for (int j = 1; j < n; j++)
- {
- if (arr[i - 1][j] == arr[i][j] || arr[i][j - 1] == arr[i][j])
- {
- ok = false;
- break;
- }
- if (arr[0][j - 1] == arr[0][j])
- {
- ok = false;
- break;
- }
- }
- }
- if (ok)
- {
- cout << endl << "yes";
- }
- else
- {
- cout << endl << "no";
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment