pascal 程序 帮忙看下

来源:百度知道 编辑:UC知道 时间:2024/06/09 22:27:53
program subway(input,output);
const o=25;
type sz=array[1..o] of integer;
var
input,p:text;
a:array[1..o,1..o] of integer;
c:array[1..o] of boolean;
q,dm:sz;
u,s,z,k,i,j,m,n:integer;
front,tail:integer;
procedure init;
begin
read(input,n,m,k,s);
for i:=1 to m+n do
for j:=1 to m+n do a[i,j]:=0;

for i:=1 to m do
read(input,dm[i]);
for u:=1 to k do
begin
read(input,i,j);
a[i,j]:=1;
a[j,i]:=1;
end;
end;

procedure bfs(x:integer);
var i,j:integer;
begin
front:=1;
tail:=1;
q[1]:=x;
fillchar(c,sizeof(c),false);
c[q[front]]:=true;

while front<=tail do
begin
for i:=1 to n+m do
for j:=1 to m do
begin
if i=dm[j] then exit;

不知道这样行不行 应为我不知道程序的意图。

program subway(input,output);
const o=25;
type sz=array[1..o] of integer;
var
input,p:text;
a:array[1..o,1..o] of integer;
c:array[1..o] of boolean;
q,dm:sz;
u,s,z,k,i,j,m,n:integer;
front,tail:integer;
procedure init;
begin
read(n,m,k,s);
for i:=1 to m+n do
for j:=1 to m+n do a[i,j]:=0;

for i:=1 to m do
read(dm[i]);
for u:=1 to k do
begin
read(i,j);
a[i,j]:=1;
a[j,i]:=1;
end;
end;

procedure bfs(x:integer);
var i,j:integer;
begin
front:=1;
tail:=1;
q[1]:=x;
fillchar(c,sizeof(c),false);
c[q[front]]:=true;

while front<=tail do
begin
for i:=1 to n+m do
for j:=1 to m do
begin
if i=dm[j] then exit;
if (a[q[front],i]=1) and (c[i]=false) then
begin
inc(tail);
q[tail]:=i;
c[i]:=true;
z:=i;
end;
end;
inc(front);<