POJ2503词典 Babelfish在外文中查找对应的英文

来源:互联网 发布:vb.net加载dll 编辑:程序博客网 时间:2024/05/01 07:47
A - Babelfish(6.1.2)(6.1使用词典解题实验范例)
Crawling in process...Crawling failedTime Limit:3000MS    Memory Limit:65536KB     64bit IO Format:%I64d & %I64u
SubmitStatus

Description

You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.

Input

Input consists of up to 100,000 dictionary entries, followed by a blank line, followed by a message of up to 100,000 words. Each dictionary entry is a line containing an English word, followed by a space and a foreign language word. No foreign word appears more than once in the dictionary. The message is a sequence of words in the foreign language, one word on each line. Each word in the input is a sequence of at most 10 lowercase letters.

Output

Output is the message translated to English, one word per line. Foreign words not in the dictionary should be translated as "eh".

Sample Input

dog ogdaycat atcaypig igpayfroot ootfrayloops oopslayatcayittenkayoopslay

Sample Output

cateh

loops

#include <iostream>#include<cstdio>#include<string.h>#include<map>using namespace std;int main(){    map<string,string>d;    char a[11],b[11],c[24];//b在d的作用下变成a,s在d的作用下变成out,类似于加密    while(gets(c))    {        if(strlen(c)==0)            break;        sscanf(c,"%s %s",a,b);        d[b]=a;    }    string s,out;    while(cin>>s)    {        out=d[s];        if(out.length()==0)            cout<<"eh"<<endl;        else            cout<<out<<endl;    }    return 0;}//题意为b密文的原型为a,求s密文的原型


0 0
原创粉丝点击