POJ 2503 Babelfish

map水题= =

我发现我有点太依赖map了。。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
using namespace std;
map<string,string> mp;
int main()
{
    int n;
    char str[50],s1[20],s2[20];
    mp.clear();
    while (1)
    {
        gets(str);
        if (strcmp(str,"") == 0)
            break;
        sscanf(str,"%s%s",s1,s2);


        mp[s2]=s1;
    }
    while (scanf("%s",str) != EOF)
    {
        if (mp.find(str) != mp.end())
        {
            printf("%s\n",mp[str].c_str());
        }
        else
            printf("eh\n");
    }
}


你可能感兴趣的:(POJ 2503 Babelfish)