迷宫问题

it2022-05-06  4

源码 : github.com/drdeng/maze

//// Deng Yong and HanMo Cheng// date:2015 12 14//#ifndef STACK_H#define STACK_H

//定义坐标 typedef struct coordinate{ int row;//行 int column;//列 int direction;//方向 }coordinate; //移动方向

//Move move[4]={{0,1},{1,0},{0,-1},{-1,0}}; //结构体链表 typedef struct LinkNode { coordinate data; //LinkNode *next; struct LinkNode *next;// } LinkNode , *Node;

class stack {private: LinkNode *top;public: stack() { //top=NULL; top=nullptr;//c++ 11 using nullptr not NULL } // bool initialStack(LinkNode * &top);//初始化栈 void pushStack(coordinate x);//入栈 void Clear();//清空栈 coordinate GetPop(/*LinkNode *&top, coordinate &data*/); coordinate Pop(); bool Empty();private:

};

#endif

 

//maze.h

#ifndef MAZE_H#define MAZE_H#include <iostream>#include "stack.h"#include <map>#include<string>using namespace std;

class stack;

class maze {public: maze()=default; bool find( );//寻找迷宫解 int ** InPut_maze();//生成迷宫 int **get_maze();//读取迷宫数据 void before_direct_readmaze();//在直接调用这个函数之前 // void OutPut_maze(stack p);//输出迷宫的解 void PrintPath(stack p);//以坐标形式输出迷宫 void PrintPath2(stack p);private: int M_Row;// int M_Column; int **M_maze;//迷宫二维数组 struct Move { int row; int column; };Move move[4]={{0,1},{1,0},{0,-1},{-1,0}};

};#endif

 

转载于:https://www.cnblogs.com/caffe/p/5080073.html

相关资源:迷宫问题实现

最新回复(0)