Advertisement
Mikhail-Podbolotov

Untitled

May 15th, 2024
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <fstream>
  2. #include <iostream>
  3. using namespace std;
  4. int main()
  5. {
  6.     ifstream input("input.txt");
  7.     int n = 0;
  8.     input >> n;
  9.     int** Matrix = new int*[n];
  10.     for (int i = 0; i < n; i++) {
  11.         Matrix[i] = new int[n];
  12.     }
  13.     //Read
  14.     for (int i = 0; i < n; i++) {
  15.         for (int j = 0; j < n; j++) {
  16.             input >> Matrix[i][j];
  17.         }
  18.     }
  19.     //Find isolated vertices
  20.     int res = 0;
  21.     for (int i = 0; i < n; i++) {
  22.         bool Flag = 0;
  23.         for (int j = 0; j < n; j++) {
  24.             if (j != i) {
  25.                 if (Matrix[i][j] > 0) Flag = 1;
  26.             }
  27.         }
  28.         if (!Flag) res++;
  29.     }
  30.     cout << res;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement