Maze Exploration - UVa 784 搜索
来源:互联网 发布:淘宝关注链接怎样设置 编辑:程序博客网 时间:2024/04/29 06:22
题目为PDF格式,就不粘贴了。
题意:将*可以移动到的位置标记为#,然后输出。
思路:简单的DFS,没什么了。
AC代码如下:
#include<cstdio>#include<cstring>using namespace std;char s[40][100];int len[40],num[4][2]={-1,0,0,1,1,0,0,-1};void dfs(int x,int y){ int i,j,k; if(s[x][y]!=' ') return; s[x][y]='#'; for(k=0;k<=3;k++) dfs(x+num[k][0],y+num[k][1]);}int main(){ int t,n,i,j,k; scanf("%d",&t); getchar(); while(t--) { n=0; while(true) { gets(s[++n]+1); len[n]=strlen(s[n]+1); if(s[n][1]=='_') break; } for(i=1;i<=n;i++) for(j=1;j<=len[i];j++) if(s[i][j]=='*') { s[i][j]=' '; dfs(i,j); } for(i=1;i<=n;i++) printf("%s\n",s[i]+1); }}
0 0
- Maze Exploration - UVa 784 搜索
- 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
- glove入门实战
- PerformanceCounter详解,使用方法
- 深度优先搜索(DFS)与广度优先搜索(BFS)
- Linux.
- Tornado编程实践建议(转)
- Maze Exploration - UVa 784 搜索
- hnu 12886 Cracking the Safe
- 如何发表论文
- 问题发个任务看完该户口问题
- C# 对硬件的控制
- 动态代理和AOP01
- 「捞」charAt() //返回在指定位置的字符 20140809 ①文本处理
- 微信分享给朋友及朋友圈JS代码
- 动态代理和AOP02