Pagini recente » Cod sursa (job #130443) | Cod sursa (job #1894060) | Cod sursa (job #1341536) | Cod sursa (job #2190587) | Cod sursa (job #275561)
Cod sursa(job #275561)
const nmax=10;
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])) or ((i<>j) and (c[i,j]=0)
and (c[i,k]>0) and (c[k,j]>0)) 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.