Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- const int n = 5;
- int mas[n][n] =
- {
- { 1,1,0,0,0 },
- { 1,1,1,0,0 },
- { 0,1,1,0,0 },
- { 0,0,1,1,1 },
- { 0,0,0,1,1 },
- };
- bool q = true;
- bool b = false;
- for (int i = 0; i < n && q; i++)
- {
- for (int j = i + 2; j < n && q; j++)
- {
- if (mas[i][j] != 0 || mas[j][i] != 0)
- q = false;
- }
- }
- if (q) {
- for (int i = 0; i < n - 1 && !b; i++)
- {
- for (int j = i - 1; j <= i + 1 && !b; j++)
- {
- if (j >= 0 && mas[i][j] != 0)
- {
- b = true;
- }
- }
- }
- }
- if (q && b) cout << "yes";
- else cout << "not";
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment