Pagini recente » Cod sursa (job #1896587) | Cod sursa (job #914883) | Cod sursa (job #1762722) | Cod sursa (job #2073938) | Cod sursa (job #2396014)
type tabel=array[1..100,1..100] of longint;
var n,i,j,k,a,b:longint;
t:tabel;
begin
assign(input,'royfloyd.in');
assign(output,'royfloyd.out');
reset(input);
rewrite(output);
read(n);
for i:=1 to n do
for j:=1 to n do read(t[i,j]);
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
if (t[i,k]<>0) and (t[k,j]<>0) then
if ((t[i,j]>t[i,k]+t[k,j]) or (t[i,j]=0)) and (i<>j) then
t[i,j]:=t[i,k]+t[k,j];
for i:=1 to n do begin
for j:=1 to n do write(t[i,j],' ');
writeln end;
close(input);
close(output);
end.