Advertisement
Guest User

graf2

a guest
Nov 14th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     ifstream f("date.in");
  8.  
  9.     int a[100][100]={0}, sum[100]={0};
  10.     int n, m;
  11.      f>>n;
  12.      f>>m;
  13.     for(int i=0; i<m; i++)
  14.     {
  15.         int x, y;
  16.         f>>x>>y;
  17.         a[x][y]=1;
  18.         a[y][x]=1;
  19.     }
  20.     f.close();
  21.  
  22.     for(int i=1; i<=n; i++)
  23.     {
  24.         int s=0;
  25.         for(int j=1; j<=n; j++)
  26.         {
  27.             //s+=a[j][i];
  28.             s+=a[i][j];
  29.         }
  30.         a[0][i]=s;
  31.         if(s == 0)
  32.             cout<<"nodul "<<i<<" este izolat"<<endl;
  33.         if(s == 1)
  34.             cout<<"nodul "<<i<<" este terminal"<<endl;
  35.     }
  36.     int max=a[0][1];
  37.     for(int i=1; i<=n; i++)
  38.         if(a[0][i] > max)
  39.             max=a[0][i];
  40.  
  41.     for(int i=1; i<=n; i++)
  42.         if(a[0][i] == max)
  43.             cout<<"nodul "<<i<<" are grad maxim = "<<a[0][i]<<endl;
  44.  
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement