i
cludeltstdiohgtr
i
cludeltmallochgtr
i
cludeltstdlibhgtr
i
cludelttimehgtr
i
cludeltmathhgtr
i
cludequotLBDLhquot链表队列r
r
墙或通路及前进方向符号定义r
defi
eWALL0代表当前格子是墙r
defi
ePATH1代表是通路且未走过r
defi
eRIGHT1代表是通路且从其向右走r
defi
eDOWN2代表是通路且从其向下走r
defi
eLEFT3代表是通路且从其向左走r
defi
eUP4代表是通路且从其向上走r
defi
eZS5ttt左上r
defi
eZX6ttt左下r
defi
eYS7ttt右上r
defi
eYX8ttt右下r
defi
eBACK9代表是通路且从其后退一步r
defi
eDESTINATION10代表当前格子是通路且是目标位置r
r
r
typedefi
tMazeType1010最外凿初始化成墙,实际含88个格子r
typedefi
tStatusr
typedefi
tElemType迷宫数组中的元素类型r
r
迷宫求解的具体算法r
r
StatusMakeMazeMazeTypemazer
r
生成迷宫,0表示通PATH1表示不通WALLr
PosTypemr
sra
dtimeNULL随机数的产生
ra
dYX1X
为XY之间的随机数r
formy0mylt9myr
r
maze0myWALLr
maze9myWALLr
tr
formx0mxlt9mxr
r
mazemx0WALLr
mazemx9WALLr
r
r
formx1mxlt9mxr
formy1mylt9myr
mazemxmyra
d2r
随机数取到0到RAND_MAX之间的任何数,r
对2取余数只产生0,1r
ra
d1010r
retur
OKtttr
r
r
打印迷宫,使其成为一幅图r
voidPri
tMazeMazeTypemazer
r
i
txyr
pri
tfquotquotr
forx0xlt9xr
pri
tfquotdquotxr
pri
tfquot
quotr
forx0xlt9xr
r
pri
tfquotdquotxr
fory0ylt9yr
r
switchmazexyr
r
caseWALLr
pri
tfquot■quotbreakr
casePATHr
pri
tfquotquotbreakr
caseRIGHTr
pri
tfquot→quotbreakr
caseDOWNr
pri
tfquot↓quotbreakr
caseLEFTr
pri
tfquot←quotbreakr
caseUPr
pri
tfquot↑quotbreakr
caseZSr
pri
tfquotquotbreakr
caseZXr
pri
tfquotquotbreakr
caseYSr
pri
tfquotquotbreakr
caseYXr
pri
tfquotquotbreakr
caseBACKr
pri
tfquotquotbreakr
caseDESTINATIONr
pri
tfquot◎quotbreaktr
defaultr
pri
tfquot错误!
quotr
exit1r
r
r
pri
tfquot
quotr
tr
r
r
位置的移动r
PosTypeNextposPosTypepositio
ElemTypedirectio
r
r
移动到下一格,向下走一步r
PosTypespotr
spotpositio
r
switchdirectio
r
r
case1r
spotybreak向右r
case2r
spotxbreak向下走r
case3r
spotybreak向左r
case4r
spotxbreak向上r
case5r
spotxspotybreak左上r
case6r
spotxspotybreakr