Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void citire()
- { int i,j,x,y;
- f>>n>>m;
- for(i=1;i<=n;i++)
- for(j=1;j<=n;j++)
- if(i==j) c[i][j]=0;
- else c[i][j]=max;
- for(i=1;i<=m;i++)
- { f>>x>>y;
- c[x][y]=1;
- }
- }
- void rf()
- { int i,j,k;
- for(k=1;k<=n;k++)
- for(i=1;i<=n;i++)
- for(j=1;j<=n;j++)
- if(c[i][j]>c[i][k]+c[k][j])
- c[i][j]=c[i][k]+c[k][j];
- }
- void afis()
- { int i,j;
- for(i=1;i<=n;i++)
- { for(j=1;j<=n;j++)
- if(c[i][j]==max) g<<"- ";
- else g<<c[i][j]<<" ";
- g<<endl;
- }
- }
- void main()
- { citire();
- afis();
- rf();
- g<<endl;
- afis();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement