dfs实现迷宫

这篇博客分享了使用深度优先搜索(DFS)解决迷宫问题的思路和成果,作者表达了对编程日益增长的兴趣。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

自己想了一晚上没睡觉的成果。

我能说我现在越来越觉得编程有趣了么~

堆栈的头文件

#include"stdafx.h"
#define DEFAULTSIZE 100;
#define OK 1;
#define FALSE 0;


template<class ElemType>//回调函数
void visit(ElemType x)
{
	cout << x.row<<","<<x.col << endl;

}
template<class ElemType>
class Stack //抽象类 
{
public:
	virtual int Length() = 0;
	virtual bool Push(ElemType e) = 0;
	virtual bool Pop(ElemType&x) = 0;
	virtual bool Read(ElemType&x) = 0;
	virtual void Clear() = 0;


}; //Stack
template<class ElemType>
class SqStack :public Stack<ElemType>//Stack的顺序栈继承
{
private:
	ElemType *stack;//栈的存储指针 动态存储分布
	int size;
	int top;
public:
	SqStack(int n = 0);
	~SqStack();
	void Clear();
	int Empty();
	int Full();
	int Length();
	int Size();
	bool Push(ElemType e);
	bool Pop(ElemType&x);
	bool Read(ElemType&x);
	int Traverse(void(*visit)(ElemType));


};


template<class ElemType>
SqStack<ElemType>:
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值