UVA 10010 沃尔多夫在哪里
来源:互联网 发布:淘宝没有花呗支付方式 编辑:程序博客网 时间:2024/05/01 04:35
字符串基础题目
讨厌的scanf
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>using namespace std;///#define INF 0xffffff7#define MAXN 60char grid[MAXN][MAXN];int m, n, kk;char word[MAXN];const int rd[]={-1, -1, 0, 1, 1, 1, 0, -1},cd[]={0, 1, 1, 1, 0, -1, -1, -1};bool search_word(int startrow, int startcol, int len){int i, j;for (i = 0; i < 8; i++){j = 0;int temprow = startrow;int tempcol = startcol;while (j < len){if (temprow < 0 || temprow >= m || tempcol < 0 || temprow >= n)break;if ( (grid[temprow][tempcol] == word[j]) || (grid[temprow][tempcol] - word[j] == 'A' - 'a') || (word[j] - grid[temprow][tempcol] == 'A' - 'a')){temprow += rd[i];tempcol += cd[i];j++;}else break;}if (j == len)return true;}return false;}int main(){///int i, j;int nCases;scanf("%d", &nCases);//cin >> nCases;while (nCases--){ memset(grid, 0, sizeof(grid));scanf("%d%d", &m, &n);for (i = 0; i < m; i++){getchar();for (j = 0; j < n; j++)scanf("%c", &grid[i][j]);}//cin >> grid[i][j];scanf("%d", &kk);getchar();for (i = 0; i < kk; i++){gets(word);bool flag = false;int len = strlen(word);for (j = 0; j < m; j++){for (int k = 0; k < n; k++){if (search_word(j, k, len)){printf("%d %d\n", j + 1, k + 1);flag = true;break;}}if (flag)break;}}if (nCases != 0)printf("\n");} /// return 0;}
- UVA 10010 沃尔多夫在哪里
- UVA 10474 大理石在哪里
- 在哪里?
- 《在哪里》
- 在哪里?
- 在哪里?
- uva 10010 我的哪里错了呢。。。
- 悟空在哪里?奶妈在哪里?
- 全局变量在哪里声明,在哪里定义
- 路径在哪里啊 路径在哪里
- 春天在哪里,Android源码在哪里。
- 心在哪里,时间就在哪里
- 时间在哪里,成就就在哪里
- 心在哪里风景就在哪里
- 周末,心情在哪里?
- 爱在哪里?!
- IT出路在哪里?
- 你在哪里
- USBISP与USBASP
- 解题报告:hdu1242 zoj1649 Rescue
- JAVA重命名文件夹下的全部文件
- 函数指针及回调函数
- 开发者必须了解的html5在wap时代前的最新存储革命
- UVA 10010 沃尔多夫在哪里
- uva 10700 - Camel trading
- extern "C"的用法解析
- ubuntu下PATH路径的设置——工作笔记
- NSInvocation简单使用
- SVN源码服务器搭建-详细教程
- ArrayList,LinkedList源码分析
- 【0.9%】SPOJ7758 Grwoing Strings 解题报告 + AC代码 + 思路 + AC自动机简短总结
- atoi()和itoa()的标准源码实现