用栈实现迷宫问题

#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#define MAXSIZE 500 //栈最大的容量
#define MAXLENGTH 20//设置最大的行和列是20 20*20
typedef struct{
int x;
int y;
}PosType;//PosType 坐标类型的变量PosType

typedef struct {
int ord;//用于存放路线
PosType seat;
int di;//用于指示下一个方向
} SElemType;//栈里面存放的每个元素的类型

typedef struct {
SElemType *top;
SElemType base;
//int stacksize;
}SqStack; //top和base是指向SElemType类型的变量的
PosType begin,end;//定义迷宫的出入口坐标 全局变量
PosType direc[4]={ {0,1},{1,0},{0,-1},{-1,0},};//移动方向依次为东南西北
int curstep=1;//记录路径的一个东西
void InitStack(SqStack
);
void Push(SqStack *S,SElemType e);
bool Pop(SqStack *S,SElemType e);
bool StackEmpty(SqStack S);
void Init(void);
void Print(void );
bool Pass(PosType b);
void MarkPrint(PosType b);
void NextPos(PosType *b

  • 20
    点赞
  • 93
    收藏
    觉得还不错? 一键收藏
  • 8
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值