/*
2016年10月10日19:48:47
C++
迷宫算法
*/
#include <iostream>
#include <stack>
using namespace std;
void InitMaze(char **maze,int x,int y) {
for (int i = 0; i < y+2; i++)
maze[i] = new char[x+2];
for (int i = 0; i < y + 2; i++) {
for (int j = 0; j < x + 2; j++)
maze[i][j] = cin.get();
cin.get();
}
}
void Display(char **maze,int x,int y) {
cout << endl << endl;
for (int i = 0; i < y; i++) {
for (int j = 0; j < x; j++)
cout << maze[i][j];
cout << endl;
}
}
int *GetStart(char **maze, int x, int y) {
//没有围墙
int *s = new int[2];
for (int i=0;i<y + 2;i++)
for (int j=0;j<x + 2;j++)
if (maze[i][j] == 'S') {
s[0] = i; s[1] = j;
return s;
}
s[0] = y; s[1] = x;
return s;
}
int *GetEnd(
C++迷宫
最新推荐文章于 2024-02-03 08:07:54 发布
本文深入探讨了使用C++编程语言实现迷宫算法的过程,涵盖了数据结构的选择与设计,详细解析了如何构建和解决迷宫问题。通过实例分析,展示了不同算法如深度优先搜索(DFS)和广度优先搜索(BFS)在迷宫求解中的应用。文章还讨论了优化策略,以提高算法效率并降低复杂度。
摘要由CSDN通过智能技术生成