Pagini recente » Diferente pentru utilizator/test.php intre reviziile 120 si 121 | Cod sursa (job #646447) | Cod sursa (job #524319) | Cod sursa (job #101334) | Cod sursa (job #741672)
Cod sursa(job #741672)
var t:array[1..100,1..100] of integer;
i,j,k,n:integer;
function min(a,b:integer):integer;
begin
if a>b then min:=b else min:=a;
end;
BEGIN
assign(input,'royfloyd.in');
reset(input);
readln(n);
for i:=1 to n do
begin
for j:=1 to n do
begin
read(t[i,j]);
if t[i,j]=0 then t[i,j]:=2000;
end;
readln;
end;
close(input);
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
t[i,j]:=min(t[i,j],t[i,k]+t[k,j]);
for i:=1 to n do
t[i,i]:=0;
assign(output,'royfloyd.out');
rewrite(output);
for i:=1 to n do
begin
for j:=1 to n do
write(t[i,j],' ');
writeln;
end;
close(output);
END.