Pagini recente » Cod sursa (job #1006965) | Cod sursa (job #20167) | Cod sursa (job #1066543) | Cod sursa (job #815876) | Cod sursa (job #535514)
Cod sursa(job #535514)
type matrice=array[0..101,0..101] of integer;
var a:matrice;
n:integer;
procedure citire;
var i,j:integer;
begin
assign(input,'royfloyd.in');reset(input);
readln(n);
for i:=1 to n do
for j:=1 to n do begin
read(a[i,j]);
if (a[i,j]=0) and (i<>j) then a[i,j]:=maxint;
end;
close(input);
end;
procedure roy;
var i,j,k:integer;
begin
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
if (a[i,k]+a[k,j]<a[i,j]) then
a[i,j]:=a[i,k]+a[k,j];
end;
procedure scrie;
var i,j:integer;
begin
assign(output,'royfloyd.out');rewrite(output);
for i:=1 to n do begin
for j:=1 to n do
write(a[i,j],' ');
writeln;
end;
close(output);
end;
begin
citire;
roy;
scrie;
end.