hdoj1880

来源:互联网 发布:怎么提高淘宝权重 编辑:程序博客网 时间:2024/05/22 16:39

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

struct dictionary
{
 char word[23];
 char function[81];
}
dict[100000];

char word[23];
char function[81];
char search[104];

void strcpy1(char *src,char *dst)
{
 dst +=1 ;
 while(*dst != '/0')
 {
  *src++ = *dst++;
 }
 *src = '/0';
}

void visit(char *p)
{
 p += 1;
 while(*p != ']') /* ! */
 {
  printf("%c",*p);
  p++;
 }
 printf("/n");
}
 


int  main()
{
 int j,k,n;
 int flag = 0;
 int count;
 scanf("%s",word);
 count=0;
 while(strcmp(word,"@END@") != 0)
 {
  gets(function);

  strcpy(dict[count].word,word);
  strcpy1(dict[count].function,function);
  count++;
  scanf("%s",word);

 }


 scanf("%d",&n);
 getchar();    /* ! */
 for(k=1; k <= n; k++)
 {
  flag = 0;

  gets(search);  /* ! */

  for(j=0;j<count;j++)
  {
   if(strcmp(dict[j].word,search) == 0)
    {
    flag = 1;
    printf("%s/n",dict[j].function);
 break;
    }
   else if(strcmp(dict[j].function,search) == 0)
    {
    flag = 1;
    visit(dict[j].word);
 break;
    }
   else
    {
    }
  }

  if(flag == 0)
   printf("what?/n");
 }


 return 0;

}

 

原创粉丝点击