Pagini recente » Cod sursa (job #1109234) | Cod sursa (job #2984384) | Cod sursa (job #1146601) | Cod sursa (job #1086038) | Cod sursa (job #412162)
Cod sursa(job #412162)
const inf=10000;
var c,tata:array[1..100,1..100] of integer;
i,j,k,n:byte;
f:text;
procedure citire;
begin
assign(f,'royfloyd.in');reset(f);
read(f,n);
for i:=1 to n do
for j:=1 to n do
{begin }
read(f,c[i,j]);
{if (i<>j) and (c[i,j]=0) then c[i,j]:=inf;
end; }
close(f);
end;
procedure royfloyd;
begin
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
if (c[i,k]<>0) and (c[k,j]<>0) then
if (c[i,j]>c[i,k]+c[k,j]) then
begin
c[i,j]:=c[i,k]+c[k,j];
tata[i,j]:=tata[k,j];
end;
end;
procedure scrie;
begin
assign(f,'royfloyd.out');rewrite(f);
for i:=1 to n do
begin
for j:=1 to n do
write(f,c[i,j],' ');
writeln(f);
end;
close(f);
end;
begin
citire;
royfloyd;
scrie;
end.