输入数据后201错误,范围溢出。。。哪位oi大牛帮我下。谢谢
program danyuan;
const n=10;
type
path=record
length:real;
pre:0..n;
end;
var
adj:array[1..n,1..n]of real;
dist:array[1..n]of path;
i,j,k,e,u,w:longint;
min:real;
procedure print(i:longint);
begin
if i=1 then write(i)
else
begin
print(dist[i].pre);
write(dist[i].pre);
end;
end;
begin
for i:=1 to n do
begin
dist[i].length:=maxint;
for j:=1 to n do
adj[i,j]:=maxint;
end;
read(v,e);
for k:=1 to e do
begin
read(i,j,w);
adj[i,j]:=w;
end;
for i:=1 to e do
begin
dist[i].length:=adj[1,i];
if dist[i].length<>maxint then dist[i].pre:=1
else dist[i].pre:=0;
end;
adj[1,1]:=1;
repeat
u:=0;
min:=maxint;
for i:=1to e do
if (adj[i,i]=0) and (dist[i].length<min) then
begin
u:=i;
min:=dist[i].length;
end;
if u<>0 then
begin
adj[u,u]:=1;
for i:=1 to e do
if (adj[i,i]=0) and (dist[i].length>dist[u].length+adj[u,i]) then
begin
dist[i].length:=dist[u].length+adj[u,i];
dist[i].pre:=u;
end;
end;
until u=0;
for i:=1 to e do
begin
print(i);
write(dist[i].length);
end;
end.
program danyuan;
const n=10;
type
path=record
length:real;
pre:0..n;
end;
var
adj:array[1..n,1..n]of real;
dist:array[1..n]of path;
i,j,k,e,u,w:longint;
min:real;
procedure print(i:longint);
begin
if i=1 then write(i)
else
begin
print(dist[i].pre);
write(dist[i].pre);
end;
end;
begin
for i:=1 to n do
begin
dist[i].length:=maxint;
for j:=1 to n do
adj[i,j]:=maxint;
end;
read(v,e);
for k:=1 to e do
begin
read(i,j,w);
adj[i,j]:=w;
end;
for i:=1 to e do
begin
dist[i].length:=adj[1,i];
if dist[i].length<>maxint then dist[i].pre:=1
else dist[i].pre:=0;
end;
adj[1,1]:=1;
repeat
u:=0;
min:=maxint;
for i:=1to e do
if (adj[i,i]=0) and (dist[i].length<min) then
begin
u:=i;
min:=dist[i].length;
end;
if u<>0 then
begin
adj[u,u]:=1;
for i:=1 to e do
if (adj[i,i]=0) and (dist[i].length>dist[u].length+adj[u,i]) then
begin
dist[i].length:=dist[u].length+adj[u,i];
dist[i].pre:=u;
end;
end;
until u=0;
for i:=1 to e do
begin
print(i);
write(dist[i].length);
end;
end.
