uva10452
来源:互联网 发布:怎么搜索淘宝店铺地址 编辑:程序博客网 时间:2024/06/05 00:17
水题
#include <iostream>#include <stdio.h>using namespace std;char map[10][10];int m,n,count;int p[3][2]= {0,-1,0,1,-1,0};string s="IEHOVA#";bool dfs(int x,int y){ if(map[x][y-1]==s[count]) { count++; printf("left"); if(count==7) { printf("\n"); return true; } else printf(" "); return dfs(x,y-1); } else if(map[x][y+1]==s[count]) { count++; printf("right"); if(count==7) { printf("\n"); return true; } else printf(" "); return dfs(x,y+1); } else { count++; printf("forth"); if(count==7) { printf("\n"); return true; } else printf(" "); return dfs(x-1,y); }}int main(){ int t; cin>>t; while(t--) { count=0; scanf("%d %d",&m,&n); for(int i=1; i<=m; i++) for(int j=1; j<=n; j++) scanf(" %c",&map[i][j]); for(int i=1; i<=n; i++) if(map[m][i]=='@') dfs(m,i); } return 0;}
阅读全文
0 0
- uva10452
- UVa10452 - Marcus
- dfs-Marcus, help!-uva10452
- 哈希表的原理详解
- Ubuntu14.04安装有道词典
- Leetcode 188. Best Time to Buy and Sell Stock IV
- Linux文本操作三剑客(sed, awk, grep)——grep
- c语言以数据块的形式对文件数据进行操作
- uva10452
- 【NOIP2017提高A组集训10.21】 总结
- 删除除了id号不同,其他都相同的学生冗余信息
- VIJOS-P1626 爱在心中
- 任正非
- Window7+python3.6.1 安装basemap
- Servlet
- 096: 复习习题 求导题型 Case4:变积分限函数导数;Case5:高阶导数;Case6:分段函数求导
- maven web工程提示Cannot detect Web Project version. Please specify version of Web Project through Maven