Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- using namespace std;
- int main()
- {
- ifstream input("input.txt");
- int n = 0;
- input >> n;
- int** Matrix = new int*[n];
- for (int i = 0; i < n; i++) {
- Matrix[i] = new int[n];
- }
- //Read
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- input >> Matrix[i][j];
- }
- }
- //Find isolated vertices
- int res = 0;
- for (int i = 0; i < n; i++) {
- bool Flag = 0;
- for (int j = 0; j < n; j++) {
- if (j != i) {
- if (Matrix[i][j] > 0) Flag = 1;
- }
- }
- if (!Flag) res++;
- }
- cout << res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement