Ignatius is so lucky that he met a Martian yesterday. But he didn't know the language the Martians use. The Martian gives him a history book of Mars and a dictionary when it leaves. Now Ignatius want to translate the history book into English. Can you help him?
START from fiwo hello difh mars riwosf earth fnnvk like fiiwj END START difh, i'm fiwo riwosf. i fiiwj fnnvk! END
hello, i'm from mars.
i like earth!
Huge input, scanf is recommended.
//
// main.cpp
// B - stl 的 map
//
// Created by 徐智豪 on 2017/3/28.
// Copyright © 2017年 徐智豪. All rights reserved.
//
#include <iostream>
#include <map>
#include <string>
#include <stdio.h>
using namespace std;
int main(int argc, const char * argv[]) {
map<string,string> dic;
string start,a,b;
cin>>start;
while(start=="START")
{
cin>>a;
if(a=="END")
break;
cin>>b;
dic[b]=a;
}
cin>>start;
getchar();
string tmp;
string cmp;
while(start=="START")
{
getline(cin,tmp);
if(tmp=="END")
break;
b="";
for(int i=0;i<tmp.size();i++)
{
if(tmp[i]<'a'||tmp[i]>'z')
{
if(dic[b]!=cmp)
{
cout<<dic[b];
}
else
{
cout<<b;
}
b="";
cout<<tmp[i];
}
else
{
b+=tmp[i];
}
}
cout<<endl;
}
return 0;
}