Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int a[100][100] = {0};
  8.     int n, m;
  9.     cin >> n >> m;
  10.     for(int i = 0; i < m; i++)
  11.     {
  12.         int x, y;
  13.         cin >> x >> y;
  14.         a[x][y] = 1;
  15.         a[y][x] = 1;
  16.     }
  17.     for(int i = 1; i <= n; i++)
  18.     {
  19.         int s = 0;
  20.         for(int j = 1; j <= n; j++)
  21.         {
  22.             s += a[i][j];
  23.             s += a[j][i];
  24.         }
  25.         if(s == 0)
  26.             cout << "Nodul " << i << " este nod izolat\n";
  27.         if(s == 1)
  28.             cout << "Nodul " << i << " este nod terminal\n";
  29.     }
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement