迷宫问题求解培训资料.pptVIP

  • 4
  • 0
  • 约小于1千字
  • 约 12页
  • 2018-04-09 发布于天津
  • 举报
迷宫问题求解培训资料.ppt

迷宫求解;迷宫求解;需要解决的问题:;1、表示迷宫的数据结构;;迷宫的定义: #define m 8 /*迷宫的实际行*/ #define n 8 /*迷宫的实际列*/ int maze [m+2][n+2] ; ;2、试探方向;试探顺序规定为:从正东沿顺时针方向;栈中每个元素的组成: 通道块在路径上的序号 坐标位置 前进方向(东为1,南为2,西为3,北为4) 栈元素的类型定义: typedef struct { int ord; PosType seat; int di; }SElemType;;;Status MazePath ( MazeType maze, PosType start, PosType end ) { InitStack(S); curpos = start; curstep = 1; do { if (Pass (curpos)) { FootPrint (curpos); e = ( curstep, curpos, 1 ); Push (S,e); if ( curpos == end ) return (TRUE); curpos = NextPos ( curpos, 1 ); curstep++; } else if (!StackEmpty(S)) { Pop (S,e); while (e.di==4 !StackEmpty(S)) { MarkPrint (e.seat); Pop (S,e); } if (e.di4) { e.di++; Push ( S, e); curpos = NextPos (curpos, e.di ); } } } while ( !StackEmpty(S) ); return (FALSE);

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档