Pagini recente » Rating Guta Alexandru Samir (sammy20) | Monitorul de evaluare | Istoria paginii utilizator/niculasuditum | Cod sursa (job #137846) | Cod sursa (job #144979)
Cod sursa(job #144979)
#include <stdio.h>
#define min(a,b) ((a<b)?a:b)
long n,i,j,k,a[128][128];
int main(){
freopen("royfloyd.in","r",stdin);
freopen("royfloyd.out","w",stdout);
scanf("%ld",&n);
for (i=1;i<=n;i++)
for (j=1;j<=n;j++)
scanf("%ld",&a[i][j]);
for (k=1;k<=n;k++)
for (i=1;i<=n;i++)
for (j=1;j<=n;j++)
a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
for (i=1;i<=n;i++){
for (j=1;j<=n;j++)
printf("%ld ",a[i][j]);
printf("\n");
}
return 0;
}