• UVa 10010 Where's Waldorf?


    #include<stdio.h>
    #include<string.h>
    #define maxn 57
    long test,m,n,k;
    char r[maxn][maxn];
    const long xd[]={-1,-1,0,1,1,1,0,-1},yd[]={0,1,1,1,0,-1,-1,-1};
    void search(const char *a,long &x,long &y)
    {
        long pos,xx,yy;
        for(long i=1;i<=m;i++)
        for(long j=1;j<=n;j++)
          if(r[i][j]==a[0])
          {
             for(long t=0;t<8;t++)
             {
                pos=0;xx=i;yy=j;
                while(a[pos]&&a[pos]==r[xx][yy])
                {xx+=xd[t];yy+=yd[t];pos++;}
                if(a[pos]==0)
                {x=i;y=j;return;}
             }
          }
    }
    int main()
    {
        scanf("%ld",&test);
        for(long cas=1;cas<=test;cas++)
        {
           long x,y;
           char word[maxn];
           if(cas>=2) printf("\n");
           memset(r,0,sizeof(r));
           scanf("%ld%ld",&m,&n);
           for(long i=1;i<=m;i++)
           {
              getchar();
              for(long j=1;j<=n;j++)
              {
                 scanf("%c",&r[i][j]);
                 if(r[i][j]>='a'&&r[i][j]<='z') r[i][j]+='A'-'a';
              }
           }
           scanf("%ld",&k);
           for(long i=1;i<=k;i++)
           {
              scanf("%s",word);
              long j=0;
              while(word[j])
              {
                 if(word[j]>='a'&&word[j]<='z') word[j]+='A'-'a';
                 j++;
              }
              search(word,x,y);
              printf("%ld %ld\n",x,y);
           }
        }
    return 0;
    }
    
  • 相关阅读:
    如何计算二进制数的取值范围
    理解网络请求中的连接超时和读取超时
    两行代码玩转Spring Data排序和分页
    面试必问Elasticsearch倒排索引原理
    你知道Java的四种引用类型吗
    抛弃配置后的Spring终极教程
    Python学习第二篇
    Python
    关于always块内for循环的执行方式
    三态门实现“一读多写”总线结构
  • 原文地址:https://www.cnblogs.com/rollenholt/p/2410779.html
Copyright © 2020-2023  润新知