pascal题 迷宫

来源:百度知道 编辑:UC知道 时间:2024/05/30 05:10:21

const
Road:array[1..8,1..8]of 0..3=((1,0,0,0,0,0,0,0),
(0,1,1,1,1,0,1,0),
(0,0,0,0,1,0,1,0),
(0,1,0,0,0,0,1,0),
(0,1,0,1,1,0,1,0),
(0,1,0,0,0,0,1,1),
(0,1,0,0,1,0,0,0),
(0,1,1,1,1,1,1,0)); {迷宫数组}

FangXiang:array[1..4,1..2]of -1..1=((1,0),(0,1),(-1,0),(0,-1));{四个移动方向}
WayIn:array[1..2]of byte=(1,1); {入口坐标}
WayOut:array[1..2]of byte=(8,8); {出口坐标}
Var i,j,Total:integer;

Procedure Output;
var i,j:integer;
Begin
For i:=1 to 8 do begin
for j:=1 to 8 do begin
if Road[i,j]=1 then write(#219); {1:墙}
if Road[i,j]=2 then write(' '); {2:曾走过但不通的路}
if Road[i,j]=3 then write(#03) ; {3:沿途走过的畅通的路}
if Road[i,j]=0 then write(' ') ; {0:原本就可行的路}
end; writeln;
end; inc(total); {统计总数} readln;
end;

Function Ok(x,y,i:byte):boolean;