###### 迷宫
program migong;
type node=record
xx,yy:longint;
end;
all=array[1..10,1..10]of longint;
const n=400;
dx:array[1..4]of longint=(0,1,0,-1);
dy:array[1..4]of longint=(1,0,-1,0);
a:all=((0,0,0,0,0,0,1,0,1,1),
(0,1,0,1,1,0,0,0,0,0),
(0,1,0,1,1,0,1,1,1,0),
(0,1,0,0,0,0,0,1,0,0),
(0,1,1,1,1,1,1,1,1,1),
(0,0,0,1,0,1,0,0,0,0),
(0,1,1,1,0,0,0,1,1,1),
(0,0,0,0,0,1,0,0,0,0),
(1,1,0,1,1,1,0,1,1,0),
(1,1,1,1,1,1,0,1,1,1));
state:array[1..n]of node;
father:array[1..n]of longint;
function check:boolean;
begin
check:=false;
if (nx<1)or(nx>10)or(ny<1)or(ny>10) then
check:=false
else if a[ny,nx]=1 then check:=false
else check:=true;
end;
function dupe:boolean;
var i,j:longint;buf:boolean;
begin
buf:=false;i:=0;
repeat
inc(i);
if (state[i].xx=state[tail].xx)and(state[i].yy=state[tail].yy)then
buf:=true else buf:=false
until buf or(i>=tail-1);
dupe:=buf;
end;
procedure print;
var buf:array[1..n]of longint;
i,j,m:longint;
begin
m:=1;j:=tail;buf[1]:=j;
while j>0 do
begin
j:=father[j];
inc(m);buf[m]:=j;
end;
for i:=m-1 downto 2 do
write('(',state[buf[i]].xx,',',state[buf[i]].yy,')','--');
writeln('(',state[buf[1]].xx,',',state[buf[1]].yy,')');
halt;
end;
begin
x1:=8;y1:=1;x2:=7;y2:=10;
state[1].xx:=x1;
state[1].yy:=y1;
repeat
for k:=1 to 4 do
if check then
begin
inc(tail);
state[tail].xx:=nx;
state[tail].yy:=ny;
if dupe then dec(tail)
else if (state[tail].xx=x2)and(state[tail].yy=y2)
then print;
end;
end.

#### 一道走迷宫算法题python实现

2017-06-01 16:47:48

#### 经典迷宫问题1

2015-11-27 13:09:47

#### JS手撸数据结构系列(四) ——Prim算法与迷宫生成

2017-05-02 10:40:33

#### 迷宫及走迷宫时的最优解

2017-05-07 01:03:01

#### 深度优先算法生成迷宫——Python实现

2015-01-08 13:42:25

#### 经典迷宫算法

2016-09-20 11:12:11

#### C语言实现迷宫求解问题（详细思路+附源代码）

2016-01-03 16:59:59

#### 一个走迷宫的程序

2012-05-22 01:02:37

#### 算法编程(JAVA)--迷宫问题

2015-06-05 08:50:11

#### matlab面向对象教程【1】迷宫生成算法案例

2017-05-06 11:15:21