Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Comp Conexe
#include <iostream> using namespace std; int n,a[101][101],viz[101],comp[101],nr; void parcurgere(int x) { int lee[101],p,u,i; p=u=1; lee[1]=x; viz[x]=nr; while(p<=u) { x=lee[p]; for(i=1;i<=n;i++) { if((a[i][x])&&(!viz[i])) { viz[i]=nr; u++; lee[u]=i; } } p++; } } int main() { int i,j,max=0,curent; cin>>n; for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { cin>>a[i][j]; } } for(i=1;i<=n;i++) { if(viz[i]==0) { nr++; parcurgere(i); } } for(i=1;i<=n;i++) { comp[viz[i]]++; if(comp[viz[i]]>max) max=comp[viz[i]]; } for(i=1;i<=nr;i++) { if(comp[i]==max) { cout<<"Componenta conexa "<<i<<"\n"; for(j=1;j<=n;j++) { if(viz[j]==i) cout<<j<<" "; } cout<<"\n"; } } return 0; }
run
|
edit
|
history
|
help
0
Dulce enredo p1
perfect square
Jilebi Nimki
poprawione_i_podzielone_1
Ineritance
Breakfast Function
PrintShape
Segment Tree
StackQuiz
Dij. Algo