Pagini recente » Razvy | Cod sursa (job #1983989) | Cod sursa (job #1581874) | Cod sursa (job #388936) | Cod sursa (job #2006604)
var a,b,n,m,i,j,k:longint;
t:array[1..100,1..100] of longint;
begin
assign(input,'royfloyd.in');
reset(input);
readln(n);
for i:=1 to n do
for j:=1 to n do
begin
read(t[i,j]);
end;
close(input);
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
if ((t[i,j]>t[i,k]+t[k,j]) or (t[i,j]=0))
and (t[i,k]<>0)
and (t[k,j]<>0)
and (i<>j) then t[i,j]:=t[i,k]+t[k,j];
assign(output,'royfloyd.out');
rewrite(output);
for i:=1 to n do
for j:=1 to n do
if j=n then writeln(t[i,j]) else write(t[i,j],' ');
end.