POJ 2503 Babelfish

周赛的时候刚做过,还不知道是POJ的题嘞。

这道题直接用Map,不会出任何问题。

下面是代码:

#include <iostream>
#include <stdio.h>
#include <map>
#include <string>
#include <string.h>
using namespace std;
int main()
{
    int i,flat,in,p;
    map<string,string> map1;
    char a[50],b[20],c[20];
    while(gets(a)&&a[0]!='\0')
	{
		sscanf(a,"%s %s",&b,&c);
        map1[c]=b;
    }
    while(gets(a)&&a[0]!='\0')
    {
        if( map1.find(a)==map1.end())
        {
            cout <<"eh"<<endl;
        }
        else
        {
            cout <<map1[a]<<endl;
        }
    }
    return 0;
}


posted @ 2013-08-16 09:48  、小呆  阅读(101)  评论(0编辑  收藏  举报