#include <iostream>
#include <stdio.h>
#define MaxSize 100
#define M 8
#define N 8
using namespace std;
int mg[M+2][N+2]=
{
{1,1,1,1,1,1,1,1,1,1},
{1,0,0,1,0,0,0,1,0,1},
{1,0,0,1,0,0,0,1,0,1},
{1,0,0,0,0,1,1,0,0,1},
{1,0,1,1,1,0,0,0,0,1},
{1,0,0,0,1,0,0,0,0,1},
{1,0,1,0,0,0,1,0,0,1},
{1,0,1,1,1,0,1,1,0,1},
{1,1,0,0,0,0,0,0,0,1},
{1,1,1,1,1,1,1,1,1,1}
};
typedef struct
{
int i;
int j;
int di;
} Box;
typedef struct
{
Box data[MaxSize];
int top;
} StType;
bool mgpath(int xi,int yi,int xe,int ye)
{
int i,j,k,di,find;
StType st;
st.top=-1;
st.top++;
st.data[st.top].i=xi;st.data[st.top].j=yi;
st.data[st.top].di=-1;
mg[xi][yi]=-1;
while(st.top>-1)
{
i=st.data[st.top].i;
j=st.data[st.top].j;
di=st.data[st.top].di;
if(i==xe&&j==ye)
{
printf("路径:
数据结构 用栈解迷宫源代码
最新推荐文章于 2024-03-27 00:24:14 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)