当前位置:网站首页>第十四次试验
第十四次试验
2022-07-07 07:09:00 【moyangxian】
#include<iostream>
using namespace std;
const int N=1010;
int g[N][N]={
{
1, 1, 1, 1, 1, 1 },
{
1, 0, 0, 0, 1, 1 },
{
1, 0, 1, 0, 0, 1 },
{
1, 0, 0, 0, 1, 1 },
{
1, 1, 0, 0, 0, 1 },
{
1, 1, 1, 1, 1, 1 }
};
bool vis[N][N];
struct Node{
int x,y;
}ans[N];
int cnt;
int dis[][2]={
0,1,1,0,0,-1,-1,0};
bool check(int x,int y){
if(vis[x][y]||g[x][y]==1) return true;
return false;
}
void dfs(int x,int y,int p){
ans[p]={
x,y};
if(x==4&&y==4){
cout<<"迷宫路径"<<++cnt<<":"<<endl;
for(int i=1;i<=p;i++){
cout<<'('<<ans[i].x<<','<<ans[i].y<<") ";
}
cout<<endl;
return ;
}
for(int i=0;i<4;i++){
int xx=x+dis[i][0];
int yy=y+dis[i][1];
if(check(xx,yy)) continue;
vis[xx][yy]=true;
dfs(xx,yy,p+1);
vis[xx][yy]=false;
}
}
int main(){
cout<<"迷宫对应邻接表"<<endl;
for(int i=0;i<=5;i++){
for(int j=0;j<=5;j++){
cout<<'['<<i<<','<<j<<"]:";
if(i==0||j==0||i==5||j==5){
cout<<endl;
continue;
}
for(int k=0;k<4;k++){
int xx=i+dis[k][0];
int yy=j+dis[k][1];
if(check(xx,yy)) continue;
cout<<'('<<xx<<','<<yy<<')'<<"\t";
}
cout<<endl;
}
}
cout<<"所有迷宫的路径:"<<endl;
vis[1][1]=true;
dfs(1,1,1);
return 0;
}
边栏推荐
- **Grafana installation**
- Write VBA in Excel, connect to Oracle and query the contents in the database
- VSCode+mingw64+cmake
- How will fashion brands enter the meta universe?
- Vs2013 generate solutions super slow solutions
- [bw16 application] Anxin can realize mqtt communication with bw16 module / development board at instruction
- 2020浙江省赛
- sqlplus乱码问题,求解答
- Binary tree high frequency question type
- Dynamics 365online applicationuser creation method change
猜你喜欢
Sqlplus garbled code problem, find the solution
js逆向教程第二发-猿人学第一题
网易云微信小程序
JS reverse tutorial second issue - Ape anthropology first question
【原创】程序员团队管理的核心是什么?
Over 100000 words_ Ultra detailed SSM integration practice_ Manually implement permission management
其实特简单,教你轻松实现酷炫的数据可视化大屏
Install pyqt5 and Matplotlib module
Strategic cooperation subquery becomes the secret weapon of Octopus web browser
信息安全实验二 :使用X-SCANNER扫描工具
随机推荐
章鱼未来之星获得25万美金奖励|章鱼加速器2022夏季创业营圆满落幕
Redis common commands
Oracle安装增强功能出错
PostgreSQL创建触发器的时候报错,
Addition, deletion, modification and query of ThinkPHP database
js逆向教程第二发-猿人学第一题
Octopus future star won a reward of 250000 US dollars | Octopus accelerator 2022 summer entrepreneurship camp came to a successful conclusion
JMeter JDBC batch references data as input parameters (the simplest method for the whole website)
Network request process
ViewPager2和VIewPager的區別以及ViewPager2實現輪播圖
[4G/5G/6G专题基础-146]: 6G总体愿景与潜在关键技术白皮书解读-1-总体愿景
How will fashion brands enter the meta universe?
20排位赛3
flex弹性布局
Lesson 1: hardness of eggs
信息安全实验一:DES加密算法的实现
H5 web player easyplayer How does JS realize live video real-time recording?
沙龙预告|GameFi 领域的瓶颈和解决方案
创建一个长度为6的int型数组,要求数组元素的值都在1-30之间,且是随机赋值。同时,要求元素的值各不相同。
Dynamics 365online applicationuser creation method change