zoukankan      html  css  js  c++  java
  • 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;
    }
    
  • 相关阅读:
    第一章 操作系统引论
    程序流程结构
    IE网页cab插件无法安装
    Java面试题整理(题目内容非原创)
    linux下安装字体
    博客园使用Silence主题装饰
    编码问题总结
    JUnit 4.10 新功能简介——RuleChain 和TemporaryFolder的应用
    Usage and Idioms——Rules
    Usage and Idioms——Theories
  • 原文地址:https://www.cnblogs.com/rollenholt/p/2410779.html
Copyright © 2011-2022 走看看