UVA 784-Maze Exploration#
来源:互联网 发布:海涛旅游 知乎 编辑:程序博客网 时间:2024/05/16 10:58
UVA 784-Maze Exploration
题目大意:给出字符串,*代表人,X代表障碍物,将人能够到达的区域全部用#标记,然后打印
解题思路:遍历找到*,然后dfs搜索
#include <stdio.h>#include <iostream>#include <string.h>using namespace std;int l;char ch[50][100];void dfs(int a, int b) { ch[a][b] = '#'; if(a - 1 > 0 && ch[a-1][b] == ' ') dfs(a-1, b); if(a + 1 < l && ch[a+1][b] == ' ') dfs(a+1, b); if(ch[a][b+1] == ' ') dfs(a, b+1); if(b - 1 > 0 && ch[a][b-1] == ' ') dfs(a, b-1);}int main() { int n; cin >> n; getchar(); while(n--) { memset(ch, '\0', sizeof(ch)); l = 0; while(gets(ch[l])) { if(ch[l][0] == '_') break; l++; } for(int i = 0; i < l; i++) for(int j = 0; ch[i][j] != '\0'; j++) { if(ch[i][j] == '*') dfs(i, j); } for(int i = 0; i <= l; i++) puts(ch[i]); } return 0;}
0 0
- UVa 784 Maze Exploration
- uva 784 - Maze Exploration
- uva 784 - Maze Exploration
- uva 784 - Maze Exploration
- UVa 784 - Maze Exploration
- UVA 784 - Maze Exploration
- UVa 784 - Maze Exploration
- uva 784 - Maze Exploration
- UVA 784 Maze Exploration
- uva 784 - Maze Exploration
- uva 784 - Maze Exploration
- UVA 784 Maze Exploration
- UVa 784 - Maze Exploration
- UVa 784 - Maze Exploration
- UVa 784 - Maze Exploration
- UVA 784 Maze Exploration
- UVA 784 Maze Exploration
- UVA - 784 Maze Exploration
- ionic插件基础(六)——自定义插件的demo
- Spring两大核心概念之IOC
- netty中使用IdleStateHandler来发起心跳
- HDU1031——Design T-Shirt(结构体排序)
- android线程池原理和实现
- UVA 784-Maze Exploration#
- Content-Type:application/x-www-form-urlencoded 和 multipart/form-data
- 使用tableHeaderView的时候动态改变高度
- [BZOJ4521][CQOI2016] 手机号码 - 数位DP
- apt-get remove, apt-get autoremove和aptitude remove的区别
- 每天一个linux命令(12):more命令
- Spring事务管理的五中方式
- 树结构练习——排序二叉树的中序遍历
- ElasticSearch概述及Linux下的单机ElasticSearch安装