当前位置:网站首页>第十四次试验
第十四次试验
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;
}
边栏推荐
- H5 web player easyplayer How does JS realize live video real-time recording?
- The industrial chain of consumer Internet is actually very short. It only undertakes the role of docking and matchmaking between upstream and downstream platforms
- How does mongodb realize the creation and deletion of databases, the creation of deletion tables, and the addition, deletion, modification and query of data
- What is MD5
- Using JWT to realize login function
- 網易雲微信小程序
- IIS faked death this morning, various troubleshooting, has been solved
- Addition, deletion, modification and query of ThinkPHP database
- Netease Cloud Wechat applet
- The difference between viewpager2 and viewpager and the implementation of viewpager2 in the rotation chart
猜你喜欢

Lesson 1: finding the minimum of a matrix

Use 3 in data modeling σ Eliminate outliers for data cleaning

Information Security Experiment 3: the use of PGP email encryption software

【frida实战】“一行”代码教你获取WeGame平台中所有的lua脚本

H5网页播放器EasyPlayer.js如何实现直播视频实时录像?

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

基于智慧城市与储住分离数字家居模式垃圾处理方法

Integer or int? How to select data types for entity classes in ORM

【无标题】

细说Mysql MVCC多版本控制
随机推荐
How will fashion brands enter the meta universe?
[4G/5G/6G专题基础-147]: 6G总体愿景与潜在关键技术白皮书解读-2-6G发展的宏观驱动力
细说Mysql MVCC多版本控制
第一讲:寻找矩阵的极小值
Binary tree high frequency question type
Install pyqt5 and Matplotlib module
NATAPP内网穿透
Schema-validation: wrong column type encountered in column XXX in table XXX
Niuke - Huawei question bank (61~70)
【frida实战】“一行”代码教你获取WeGame平台中所有的lua脚本
如何成为一名高级数字 IC 设计工程师(1-6)Verilog 编码语法篇:经典数字 IC 设计
Information Security Experiment 1: implementation of DES encryption algorithm
scrapy爬虫mysql,Django等
Netease Cloud Wechat applet
[Frida practice] "one line" code teaches you to obtain all Lua scripts in wegame platform
In fact, it's very simple. It teaches you to easily realize the cool data visualization big screen
How to become a senior digital IC Design Engineer (1-6) Verilog coding Grammar: Classic Digital IC Design
shake数据库中怎么使用Mongo-shake实现MongoDB的双向同步啊?
2020浙江省赛
Lecture 1: stack containing min function