Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int n;
- int input;
- cin >> n;
- int **Graph = (int**)malloc(n*sizeof(int*));
- for (int i = 0; i < n; i++) {
- Graph[i] = (int*)malloc(n*sizeof(int));
- }
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- cin >> input;
- Graph[i][j] = input;
- }
- }
- bool check = false;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- if (i == j) {
- if (Graph[i][j] == 1) check = true;
- }
- }
- }
- if (check == true) cout << "YES" << " ";
- else cout << "NO" << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement