UVA 784 Maze Exploration
来源:互联网 发布:labview 算编程吗 编辑:程序博客网 时间:2024/06/06 01:33
题意: 先找到起始位置,由起始位置开始探索迷宫,在迷宫中如果遇到墙、越界、已来过就返回,否则由该位置向四个方向继续探索。
#include <cstdio>char data[35][85];int row, column, dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};void explor(int x, int y) {if (data[x][y] == '#' || data[x][y] == 'X' || x < 0 || x == row || y < 0 || data[x][y] == 0)return;//遇到越界、已来过、墙就跳过data[x][y] = '#';//标记已来过for (int i = 0; i < 4; i++) //由该位置向 4 个方向遍历迷宫explor(x + dir[i][0], y + dir[i][1]);}int main() {int t;scanf("%d\n", &t);while (t--) {for (row = 0; gets(data[row]) && data[row][0] != '_'; row++);for (int i = 0; i < row ; i++)for (int j = 0; data[i][j] != 0; j++)if (data[i][j] == '*') //如果找到了起始点, 就从此处开始探索迷宫explor(i, j);for (int i = 0; i <= row; i++)puts(data[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
- ASP.net 用EasyUI datagrid对数据操作
- [ORA-01450] maximum key length (3215) exceeded
- linux路由功能
- MySQL常用用户管理
- oracle 11g gateway 连接sql server 2000
- UVA 784 Maze Exploration
- Android开发之接收系统广播消息
- android的logcat详细用法
- uva 10564 - Paths through the Hourglass
- NAT的match-in-vrf功能介绍
- Babelfish(字典树 or map)
- 来北京的这些日子
- hdu1282(字符串回文)
- 算法设计之,堆,堆排序,基于最大堆的最大优先队列的实现(C++实现)