📄 1.cpp
字号:
#include<stdlib.h>
#include <string.h>
#include <time.h>
#include<iostream.h>
#include"o.h"
#include"mg.h"
void main()
{
cout<<" ****************************************************************"<<endl;
cout<<" 数据结构课程设计之迷宫寻路"<<endl;
cout<<" 本程序根据你输入的行,列,复杂水平,生成一个矩阵图形迷宫。"<<endl;
cout<<" 0表示不可行走的障碍,1表示可以行走的路径。"<<endl;
cout<<" 程序自动寻路,用文字显示所有搜索的路径。"<<endl;
cout<<" 再用9标识最后走通的路径。"<<endl;
cout<<" ****************************************************************"<<endl;
Stack lj1;
stack1 s1;//存放走过的路径
zou z;
s1.InitStack(lj1,200);
int x(0),y(0),zz(0);
cout<<"行(1~10): ";
cin>>y;
cout<<"列(1~10): ";
cin>>x;
cout<<"障碍级别(1~+∞ 难度逐渐降低): ";
cin>>zz;
z.Initzou(x,y,zz);
do{
if(z.ifgoon(z))
{
s1.Push(lj1,z.xianz);
z.xingzou(z);
}
else
{
z.houtui();
}
}while(z.xianz.tbt!=4);
z.m[z.xianz.mx][z.xianz.my].tbt=9;//显示当前位置
Mg temp;
do{
temp=s1.Pop(lj1);
z.m[temp.mx][temp.my].tbt=9;
}while(!s1.StackEmpty(lj1));//给走过的路径表示成9
int i(0),j(0);
for(i=0;i<x;i++)
{
cout<<endl;
for(j=0;j<y;j++)
cout<<z.m[i][j].tbt<<" ";
}
cout<<endl<<endl;
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -