觉得浮夸了四年,漠然发现原来是浮躁了四年!

POJ 2503(Babelfish)

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 ogday
cat atcay
pig igpay
froot ootfray
loops oopslay

atcay
ittenkay
oopslay

Sample Output

cat
eh
loops

Hint

Huge input and output,scanf and printf are recommended.

Source

 
I didn't work out the problem like that just because I know little about the function of the C++.So the most important thing next is to learn more !I can!  Come on!  Green hand like me!
#include<iostream>
#include<string>
#include<map>
using namespace std;
void Getword(const string &str,string &str1,string &str2)
{
    int i=str.find_first_of(' ');
    str1=str.substr(0,i);
    int j=str.find_first_not_of(' ',i);
    str2=str.substr(j,str.length()-j);
}
map<string,string> map_match;
int main()
{
    string line;
    while(getline(cin,line))
    {
        string english;
        string foreign;
        if(line.length()==0)
          break;
        Getword(line,english,foreign);
        map_match[foreign]=english;
    }
    while(getline(cin,line))
    {
        int k=map_match.count(line);
        if(k>0)
            cout<<map_match[line]<<endl;
        else
            cout<<"eh"<<endl;
    }
    return 0;
}

  

 
posted @   heat nan  阅读(165)  评论(0编辑  收藏  举报
编辑推荐:
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
点击右上角即可分享
微信分享提示