Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. int input;
  7. cin >> n;
  8. int **Graph = (int**)malloc(n*sizeof(int*));
  9. for (int i = 0; i < n; i++) {
  10. Graph[i] = (int*)malloc(n*sizeof(int));
  11. }
  12.  
  13. for (int i = 0; i < n; i++) {
  14. for (int j = 0; j < n; j++) {
  15. cin >> input;
  16. Graph[i][j] = input;
  17. }
  18. }
  19.  
  20. bool check = false;
  21. for (int i = 0; i < n; i++) {
  22. for (int j = 0; j < n; j++) {
  23. if (i == j) {
  24. if (Graph[i][j] == 1) check = true;
  25. }
  26. }
  27. }
  28.  
  29. if (check == true) cout << "YES" << " ";
  30. else cout << "NO" << " ";
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement