计蒜客第三章:走迷宫2
发布日期:2022-02-01 13:46:32 浏览次数:24 分类:技术文章

本文共 792 字,大约阅读时间需要 2 分钟。

计蒜客习题:走迷宫2

题目

在这里插入图片描述

样例

在这里插入图片描述

代码

#include
#include
using namespace std;int v[105][105],num[105][105],n,m,xx[7]={
0,0,-1,1},yy[7]={
1,-1,0,0};char map[105][105];struct point{
int x, y; point(int xx,int yy) {
x=xx; y=yy; }};void bfs(int sx,int sy){
queue
q; q.push(point(sx,sy)); v[sx][sy]=1; while(!q.empty()) {
int x=q.front().x; int y=q.front().y; q.pop(); for(int i=0;i<4;i++) {
int tx=x+xx[i]; int ty=y+yy[i]; //cout<
<<" "<
<
n||ty<1||ty>m) continue; if(!v[tx][ty]&&map[tx][ty]!='#') { v[tx][ty]=1; //cout<
<<" "<
<
>n>>m; getchar(); for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) { cin>>map[i][j];//cout<

转载地址:https://blog.csdn.net/shidonghang/article/details/102498019 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:计蒜客第三章:八皇后问题
下一篇:计蒜客第二章:朋友

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2024年04月27日 19时42分24秒