UVa 784
来源:互联网 发布:python的idle 编辑:程序博客网 时间:2024/04/30 10:36
很水的水题,深搜一遍完事,没啥好说的,贴代码.....
/*
Uva 784
2012-10-15 20:01:07
*/
#include <stdio.h>
#include<string.h>
#include<stdlib.h>
int height;
int width;
char maze[100][100];
int sx,sy;
void DFS(int x,int y)
{
if(x>=height||y>=width||x<0||y<0||maze[x][y]!=' '&&maze[x][y]!='*'||maze[x][y]=='X')
return ;
maze[x][y]='#';
DFS(x-1,y);
DFS(x,y-1);
DFS(x+1,y);
DFS(x,y+1);
}
void read()
{
height=0;
int i=0;
int max=-1;
while(1)
{
gets(maze[i]);
if(maze[i][0]=='_')
break;
i++;
}
height=i;
for(int k=0;k<height;++k)
{
int t=strlen(maze[k]);
if(t>max)
{
max=strlen(maze[k]);
}
}
width=max;
//printf("%d %d\n",height,width);
for(int j=0;j<height;++j)
{
for(int k=0;k<width;++k)
{
if(maze[j][k]=='*')
{
sx=j;
sy=k;
}
// printf("%c",maze[j][k]);
}
// printf("\n");
}
}
void out()
{
for(int i=0;i<height;++i)
{
puts(maze[i]);
}
}
int main()
{
int num;
while(scanf("%d",&num)!=EOF)
{
getchar();
for(int i=0;i<num;++i)
{
read();
DFS(sx,sy);
out();
puts(maze[height]);
}
}
return 0;
}
- UVa 784
- uva 784
- uva 784
- uva 784
- uva 784
- UVA 784
- UVa 784 Maze Exploration
- uva 784(bfs)
- uva 784(dfs)
- uva 784 - Maze Exploration
- uva 784 - Maze Exploration
- uva 784 - Maze Exploration
- UVa 784 - Maze Exploration
- UVA 784 迷宫探索
- UVA 784 - Maze Exploration
- UVa 784 - Maze Exploration
- uva 784 - Maze Exploration
- UVA 784 Maze Exploration
- JAVA Web应用
- Valentin.PVSOL.Expert.v5.5.R3.MULTiLANGUAGE-SUBSTANCE
- 页面字符出现乱码,怎么解决
- DTD 的语法细节:元素定义
- XML Schema
- UVa 784
- 发光二极管之一——工作原理图解分析
- 浅谈木马的ASP收信方式
- W3C XML Schema 教程
- 11 java 王少飞-javaweb应用程序开发一
- web应用程序开发环境配置
- 10个出色的NoSQL数据库
- 在SAP自建 全国各大城市数据表。
- linux下rsync实现文件备份同步