当前位置:网站首页>第十四次试验
第十四次试验
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;
}
边栏推荐
- The industrial chain of consumer Internet is actually very short. It only undertakes the role of docking and matchmaking between upstream and downstream platforms
- Lecture 1: stack containing min function
- Difference between process and thread
- flink. CDC sqlserver. 可以再次写入sqlserver中么 有连接器的 dem
- Unity shader (to achieve a simple material effect with adjustable color attributes only)
- 如何成为一名高级数字 IC 设计工程师(5-2)理论篇:ULP 低功耗设计技术精讲(上)
- 牛客网——华为题库(61~70)
- 基于智慧城市与储住分离数字家居模式垃圾处理方法
- Regular matching starts with XXX and ends with XXX
- 如何使用clipboard.js库实现复制剪切功能
猜你喜欢

What development models did you know during the interview? Just read this one

csdn涨薪技术-浅学Jmeter的几个常用的逻辑控制器使用

【原创】程序员团队管理的核心是什么?

JMeter JDBC batch references data as input parameters (the simplest method for the whole website)

Unity3d interface is embedded in WPF interface (mouse and keyboard can respond normally)

Binary tree high frequency question type

沙龙预告|GameFi 领域的瓶颈和解决方案

VSCode+mingw64

其实特简单,教你轻松实现酷炫的数据可视化大屏

第一讲:寻找矩阵的极小值
随机推荐
[4G/5G/6G专题基础-147]: 6G总体愿景与潜在关键技术白皮书解读-2-6G发展的宏观驱动力
信息安全实验一:DES加密算法的实现
Over 100000 words_ Ultra detailed SSM integration practice_ Manually implement permission management
创建一个长度为6的int型数组,要求数组元素的值都在1-30之间,且是随机赋值。同时,要求元素的值各不相同。
【无标题】
在EXCEL写VBA连接ORACLE并查询数据库中的内容
Unity shader (learn more about vertex fragment shaders)
网易云微信小程序
NATAPP内网穿透
VSCode+mingw64
Mysql:select ... for update
战略合作|SubQuery 成为章鱼网络浏览器的秘密武器
基于智慧城市与储住分离数字家居模式垃圾处理方法
Network request process
Niuke - Huawei question bank (61~70)
Switching value signal anti shake FB of PLC signal processing series
The industrial chain of consumer Internet is actually very short. It only undertakes the role of docking and matchmaking between upstream and downstream platforms
In fact, it's very simple. It teaches you to easily realize the cool data visualization big screen
First issue of JS reverse tutorial
IIS faked death this morning, various troubleshooting, has been solved