#include<malloc.h>
#include<stdbool.h>
#define M 4
#define N 4
typedef struct
{
int x;
int y;
int fx;//0-3代表四个方向
}box;//压入栈中的数据类型
typedef struct
{
int incx;
int incy;
}direction;//代表方向的结构体类型
int maze[6][6]=
{
{1,1,1,1,1,1},
{1,0,0,0,0,1},
{1,1,0,1,1,1},
{1,0,0,0,1,1},
{1,1,1,0,0,1},
{1,1,1,1,1,1}
};//迷宫二维数组
direction Dir[4]=
{
{0,1},
{1,0},
{0,-1},
{-1,0}
};//探测方向二维数组
typedef struct node//栈的节点结构体
{
box data;
struct node* pNext;
}Node,*Pnode;
typedef struct stack//链栈结构体
{
Pnode pButtom;
Pnode pTop;
}Stack,*Pstack;
Pstack initsta()//初始化栈
{
Pstack s=(Pstack)malloc(sizeof(Stack));
Pnode phead=(Pnode)malloc(sizeof(Node));
s->pButtom=phead;
s->pTop=phead;
return s;
}
int push(Pstack s,box key)//压栈
{
Pnode pNew=(Pnode)malloc(sizeof(Node));
pNew->pNext=s->pTop;
s->pTop=pNew;
pNew->data.x=key.x;
pNew->data.y=key.y;
pNew->data.fx=key.fx;
return 0;
}
box pop(Pstack s)//出栈
{
box tmp;
if(s->pTop!=s->pButtom)
{
Pnode pTmp=s->pTop->pNext;
tmp.x=s->pTop->data.x;
tmp.y=s->pTop->data.y;
tmp.fx=s->pTop->data.fx;
free(s->pTop);
s->pTop=pTmp;
}
return tmp;
}
bool empty(Pstack s)//判断栈空
{
if(s->pTop==s->pButtom)
return true;
else
return false;
}
无法运行
报错内容:Id returned 1 exit status