map(映射问题)单词的对应关系

你刚从滑铁卢搬到一个大城市。这里的人讲一种难以理解的外语方言。幸运的是,你有一本字典来帮助你理解它们。

Input

输入内容包括多达100000个字典条目,后面是一个空行,后面是一条多达100000个单词的消息。每个字典条目都是一行,包含一个英语单词,后跟一个空格和一个外语单词。字典里没有外文词出现过一次。信息是外语中的一系列单词,每行一个单词。输入中的每个单词都是最多10个小写字母的序列。

Output

输出是翻译成英文的消息,每行一个字。字典中没有的外来词应译为“eh”。

Sample Input

dog ogday
cat atcay
pig igpay
froot ootfray
loops oopslay

atcay
ittenkay
oopslay

Sample Output

cat
eh
loops

 

#include<iostream>
#include<map>
#include<stdio.h>
#include<string.h>
using namespace std;
map<string,string>mp;
int main() 
{
 char str1[15],str2[15],d[100];
 while(gets(d)&&d[0]!='\0')
  {
  sscanf(d,"%s%s",&str1,&str2);
  mp[str2]=str1;
 }
 string c;
 while(cin>>c) {
  if(mp[c].size()==0)  cout<<"eh"<<endl;
  else
   cout<<mp[c]<<endl;
 }
 return 0;
 }
 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值