C++链栈实现迷宫问题

该博客介绍了一个使用C++链栈实现解决迷宫问题的方法,包括链栈的数据结构定义、初始化迷宫、路径搜索及输出路径的函数。通过用户输入迷宫大小和障碍位置,程序能够找到从起点到终点的路径。
摘要由CSDN通过智能技术生成

//CPath.h  文件

#include<iostream>
#include<fstream>
using namespace std;

class CPath   //应用程序类
{
public:
 int m[50][50];
 void Initpath(int jshux,int jshuy,int qshu);
 int path(int beginx,int beginy,int endx,int endy);
 void output(int x,int y);
};

struct Node  //
{
 int x;
 int y;
};
typedef struct stack   // 链栈
{
 int di;
 struct Node seat;
 stack *next;
}*pstack;
void Push(pstack &top,stack &c)
{
 stack *s=new(stack);
 s->di=c.di;
 s->seat=c.seat;
 s->next=top;
 top=s;
}
int Pop(pstack &top,stack &c)
{
 if(top==NULL) return 0;
 stack *p;
 c.di=top->di;
 c.seat=top->seat;
 p=top;
 top=top->next;
 delete(p);
 return 1;
}

//  CPath.cpp  文

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值