当前位置:网站首页>第十四次试验
第十四次试验
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;
}
边栏推荐
- How to speed up video playback in browser
- La différence entre viewpager 2 et viewpager et la mise en œuvre de la rotation viewpager 2
- Mysql:select ... for update
- Information Security Experiment 1: implementation of DES encryption algorithm
- Windows starts redis service
- 第一讲:寻找矩阵的极小值
- Unity shader (to achieve a simple material effect with adjustable color attributes only)
- The difference between viewpager2 and viewpager and the implementation of viewpager2 in the rotation chart
- Final keyword
- Switching value signal anti shake FB of PLC signal processing series
猜你喜欢

Mysql:select ... for update

STM32 and motor development (from stand-alone version to Networking)

Esp8266 uses TF card and reads and writes data (based on Arduino)

Arthas simple instructions

12、 Sort

第一讲:包含min函数的栈

Lecture 1: stack containing min function

MongoDB怎么实现创建删除数据库、创建删除表、数据增删改查
![[Frida practice]](/img/20/fc68bcf2f55b140d6754af6364896b.png)
[Frida practice] "one line" code teaches you to obtain all Lua scripts in wegame platform

flex弹性布局
随机推荐
How to become a senior digital IC Design Engineer (1-6) Verilog coding Grammar: Classic Digital IC Design
大佬们,有没有遇到过flink cdc读MySQLbinlog丢数据的情况,每次任务重启就有概率丢数
**Grafana installation**
JMeter JDBC batch references data as input parameters (the simplest method for the whole website)
[Frida practice] "one line" code teaches you to obtain all Lua scripts in wegame platform
Oracle installation enhancements error
大佬们,请问 MySQL-CDC 有什么办法将 upsert 消息转换为 append only 消
进程和线程的区别
網易雲微信小程序
flink. CDC sqlserver. 可以再次写入sqlserver中么 有连接器的 dem
HCIP 第一天 笔记整理
Arthas simple instructions
Octopus future star won a reward of 250000 US dollars | Octopus accelerator 2022 summer entrepreneurship camp came to a successful conclusion
【frida实战】“一行”代码教你获取WeGame平台中所有的lua脚本
H5网页播放器EasyPlayer.js如何实现直播视频实时录像?
第一讲:寻找矩阵的极小值
Create an int type array with a length of 6. The values of the array elements are required to be between 1-30 and are assigned randomly. At the same time, the values of the required elements are diffe
Information Security Experiment 3: the use of PGP email encryption software
进程间的通信方式
Use 3 in data modeling σ Eliminate outliers for data cleaning