poj 2503 Babelfish (查找 map)

题目:http://poj.org/problem?id=2503

不知道为什么 poj  的 数据好像不是100000,跟周赛的不一样

2000MS的代码:

 1 #include <iostream>
 2  #include<cstdio>
 3  #include<cstring>
 4  #include<cstdlib>
 5  #include<stack>
 6  #include<queue>
 7  #include<iomanip>
 8  #include<cmath>
 9  #include<algorithm>
10  #include<map>
11  using namespace std;
12  
13  char str[200010][30];
14  int main()
15  {
16       int i,j;
17      char s1[30];
18      map<string,int>mp;
19      i=1;
20      while(1)
21      {
22          char t; j=0;
23          if((t=getchar())=='
')
24          break;
25          str[i][j++]=t;
26          while(1)
27          {
28              t=getchar();
29              if(t==' ')
30              {
31                  str[i][j]='';
32                  break;
33              }
34              else
35              str[i][j++]=t;
36          }
37          scanf("%s",s1);
38          mp[s1]=i;
39          i++;
40          getchar();
41      }
42      while(gets(s1)!=NULL)
43      {
44          if(mp[s1]>=1)
45          printf("%s
",str[mp[s1]]);
46          else
47          printf("eh
");
48      }
49      return 0;
50  }
51  
原文地址:https://www.cnblogs.com/bfshm/p/3268761.html