Pagini recente » Cod sursa (job #859907) | Cod sursa (job #891173) | Cod sursa (job #2547937) | Cod sursa (job #2592554) | Cod sursa (job #275542)
Cod sursa(job #275542)
const nmax=100;
inf=maxint div 2;
type mat=array [1..nmax,1..nmax] of real;
mult=set of byte;
var c:mat;
d:array [1..nmax,1..nmax] of mult;
i,j,n,k:integer;
f,g:text;
begin
assign(f,'royfloyd.in');
reset(f);
assign(g,'royfloyd.out');
rewrite(g);
readln(f,n);
for i:=1 to n do
for j:=1 to n do
read(f,c[i,j]);
close(f);
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
if i<>j then
if (c[i,k]>0) and (c[k,j]>0) and (c[i,j]>c[i,k]+c[k,j]) then
c[i,j]:=c[i,k]+c[k,j];
for i:=1 to n do begin
for j:=1 to n do
write(g,trunc(c[i,j]),' ');
writeln(g);
end;
close(g);
end.