uva 784
来源:互联网 发布:wireshark for ubuntu 编辑:程序博客网 时间:2024/04/30 14:43
这题深搜和宽搜都可以,感觉最贱的是最后输入的"_" input 输入几个下划线,output输出几个,好吧我没看清题wa 了3次
dfs:
#include <stdio.h>#include <stdlib.h>#include <string.h>#define MAX 81char map[31][81];int d[4][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };int startx, starty, maxlen[31], max;char last[81];void output( void ){int i, j;for( i = 0; i < max; i++ ){for( j = 0; j < maxlen[i]; j++ )printf( "%c", map[i][j] );printf( "\n" );}puts( last );};void input( void ){char temp[81];int i, j, len, x;i = 0;while( gets(temp) ){if( temp[0] == '_' ){for( x = 0; x < strlen(temp); x++ )last[x] = '_';last[x] = '\0';break;}len = strlen( temp );maxlen[i] = len;for( j = 0; j < len; j++ ){if( temp[j] == '*' ){startx = i;starty = j;}map[i][j] = temp[j];}i++;}max = i;}void dfs( int x, int y ){int i;for( i = 0; i < 4; i++ ){int xx = x + d[i][0];int yy = y + d[i][1];if( map[xx][yy] == ' ' ){map[xx][yy] = '#';dfs(xx, yy);}}if( map[x][y] == ' ' || map[x][y] == '*' ){map[x][y] = '#';for( i = 0; i < 4; i++ )dfs( x+d[i][0], y+d[i][1] );}elsereturn;};int main(){char temp[81];int t, len, i, j;scanf( "%d\n", &t );while( t-- ){memset( map, -1, sizeof(map) );input();dfs( startx, starty );output();}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
- Ubuntu探秘之二:软件包管理系统
- Windows Server 2003升级IE6到高版本系统不支持解决方法
- Ubuntu 声卡解决办法合集
- Matlab中的RandStream
- 架构师
- uva 784
- poj1274 The Perfect Stall (匈牙利算法)
- 私有api用法
- 毕业两年了
- 五种IO模型
- 搬家到此
- Tomcat环境变量Catalina_Home配置
- iOS Application Programming Guide 摘要
- poj2533,LIS问题(n^2)