Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //19 Sa se determine persoana cea mai celebra
- //dintr-un grup
- #include <iostream>
- #include <fstream>
- using namespace std;
- int a[20][20],n,m;
- int i,j,k; int gr_int,gr_ext;
- //----------------------------------------------------------------------
- void citire()
- {
- ifstream f("date.txt");
- int x,y; f>>n>>m;
- cout<<"noduri="<<n<<endl;
- cout<<"muchii="<<m<<endl;
- for(i=1;i<=m;i++)
- {
- f>>x>>y;
- cout<<"x("<<i<<"): "<<x<<endl;
- cout<<"y("<<i<<"): "<<y<<endl;
- a[x][y]=1; // Graf Orientat
- }
- }
- //----------------------------------------------------------------------
- void rw()
- {
- for(k=1;k<=n;k++)
- for(i=1;i<=n;i++)
- for(j=1;j<=n;j++)
- if(a[i][j]==0) a[i][j]=a[i][k]*a[k][j];
- }
- //----------------------------------------------------------------------
- void afisare()
- {
- cout<<endl<<"Matricea de adiacenta este: "<<endl;
- for(i=1;i<=n;i++)
- {
- for(j=1;j<=n;j++) cout<<a[i][j]<<" ";
- cout<<endl;
- }
- cout<<endl;
- }
- //----------------------------------------------------------------------
- int main()
- {
- citire();
- rw();
- afisare();
- cout<<endl;
- for(j=1;j<=n;j++)
- {
- gr_int=0;
- gr_ext=0;
- for(i=1;i<=n;i++)
- {
- if(a[i][j]==1) gr_int++;
- if(a[j][i]==1) gr_ext++;
- }
- if(gr_int==n-1&&gr_ext==0) cout<<"celebru "<<j<<" "<<endl;
- }
- return 1337;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement