Cod sursa(job #143300)

Utilizator gabitzish1Gabriel Bitis gabitzish1 Data 26 februarie 2008 11:14:05
Problema Floyd-Warshall/Roy-Floyd Scor Ascuns
Compilator cpp Status done
Runda Marime 0.47 kb
#include <stdio.h>

int mat[100][100],x,y,z,n;

int min(int x,int y) {
if(x<y) return x;
else return y;
}

int main() {
freopen(" " ,"r",stdin);
freopen(" " ,"w",stdout);

scanf("%d",&n);
for(x=1;x<=n;x++)
for(y=1;y<=n;y++)
scanf("%d",&mat[x][y]);

for(z=1;z<=n;z++)
for(x=1;x<=n;x++)
for(y=1;y<=n;y++)
mat[x][y] = min( mat[x][z] + mat[z][y] , mat[x][y] );

for(x=1;x<=n;x++) {
for(y=1;y<=n;y++)
printf("%d ",mat[x][y]);
printf("\n");
}

return 0;
}