| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
啊啊啊啊~~ 这程序怎么会错啊,已经是全搜了#include <stdio.h>
#include <string.h>
char a[100][102]; //储存矩阵
int main()
{
int n , i , j , L , k , find , x1 , y1 , x2 , y2 , t;
char s[102];
scanf("%d" , &n);
for (i = 0; i < n; i ++) scanf("%s" , a[i]);
while (scanf("%s" , s) == 1)
{
if (s[0] == '0') break;
L = strlen(s);
if (L > n) {printf("Not found\n"); continue;}
find = 0;
for (i = 0; i < n; i ++)
{
for (j = 0; j < n; j ++)
if (a[i][j] == s[0])
{
x1 = i + 1; y1 = j + 1;
if (j + 1 >= L) //Right To Left
{
find = 1; t = 0;
for (k = j; k > j - L; k --) if (a[i][k] != s[t ++]) {find = 0; break;}
if (find) {x2 = x1; y2 = y1 - L + 1; break;}
}
if (n - j >= L) //Left To Right
{
find = 1; t = 0;
for (k = j; k < j + L; k ++) if (a[i][k] != s[t ++]) {find = 0; break;}
if (find) {x2 = x1; y2 = y1 + L - 1; break;}
}
if (i + 1 >= L) //Down To Up
{
find = 1; t = 0;
for (k = i; k > i - L; k --) if (a[k][j] != s[t ++]) {find = 0; break;}
if (find) {x2 = x1 - L + 1; y2 = y1; break;}
}
if (n - i >= L) //Up To Down
{
find = 1; t = 0;
for (k = i; k < i + L; k ++) if (a[k][j] != s[t ++]) {find = 0; break;}
if (find) {x2 = x1 + L - 1; y2 = y1; break;}
}
}
if (find) break;
}
if (find) printf("%d,%d %d,%d\n" , x1 , y1 , x2 , y2);
else printf("Not found\n");
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator