⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 base.h

📁 数据结构的迷宫求解
💻 H
字号:
#define  RANGE 10
#define ERROR 0
#define OK 1
#define OVERFLOOW -2
                   //类型声明
//迷宫类型
typedef char ARR[RANGE+2][RANGE+2];
typedef struct MazeType
{
	int m,n;
	ARR arr;//迷宫数组,加2是为了输出一个边框
}MazeType;
//栈类型
typedef struct
{
	int r,c;//迷宫中的r行c列位置
}PosType;//标点类型
typedef struct ElemType
{ 
	int step;//当前位置在路径上的“序号”
	PosType seat;//当前位置坐标
	int di;//往下一个坐标位置的方向
}ElemType;//栈的元素data的类型
typedef struct LNode
{
	ElemType data;
	LNode * next;
}LNode,*LinkStack;
typedef struct Stack
{ 
	LinkStack top;
	int size;
}Stack;//栈类型

                   //函数声明
//迷宫函数
void InitMaze(MazeType &M); //初始化迷宫M,自定义生成一个迷宫
void ShowMaze(MazeType &M);//演示迷宫
void CreatMaze(MazeType &M);//用户输入迷宫
bool MazePath(MazeType &M,PosType start,PosType end);//找出一条迷宫路径(用户自己设置起点和终点),
                                                     //成功则返回TRUE,否则返回FALSE
void PrintMaze(MazeType M);//输出迷宫
//内置函数
	bool Pass(MazeType M,PosType t);//当前位置可以通过
	void FootPrint(MazeType &M,PosType t);//留下足迹
	void MarkPrint(MazeType &M,PosType t);//不通过标记
	PosType NextPos(PosType t,int k);//下一个相邻块

//栈函数

int InitStack(Stack &S);//初始化栈
int Push(Stack &S,ElemType e);//入栈
int Pop(Stack &S,ElemType &e);//出栈
bool StackEmpty(Stack S);//若栈为空,则返回TRUE,否则返回FALSE

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -