Pagini recente » Istoria paginii runda/eusebiu1/clasament | Cod sursa (job #844184) | Cod sursa (job #456181) | Cod sursa (job #1179822) | Cod sursa (job #1174014)
const inf=1 shl 28;
var a:array[1..101,1..101] of longint;
i,j,k,n:longint;
bif,bof:array[1..1 shl 16] of char;
begin
assign(input,'royfloyd.in');
assign(output,'royfloyd.out');
reset(input);
rewrite(output);
settextbuf(input,bif);
settextbuf(output,bof);
readln(n);
for i:=1 to n do
for j:=1 to n do
begin
read(k);
if k=0 then a[i][j]:=inf
else a[i][j]:=k;
end;
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
if (a[i][j]>a[i][k]+a[k][j]) and (i<>j) then a[i][j]:=a[i][k]+a[k][j];
for i:=1 to n do
begin
for j:=1 to n do
if a[i][j]=inf then write('0 ')
else write(a[i][j],' ');
writeln;
end;
close(input);
close(output);
{Totusi este trist in lume}
end.