码迷,mamicode.com
首页 > 其他好文 > 详细

神族文字

时间:2016-12-20 00:40:14      阅读:558      评论:0      收藏:0      [点我收藏+]

标签:题目   int   cin   return   pac   lin   out   cstring   class   

题目描述:

楚继光发现图书馆里收藏有许多上古时代的魔法书,这些上古时代的魔法书使用一种传说中的“神族文字(每个词由不超过10个字小写字母组成)”来书写,幸运的是,楚继光手中恰好有一本词典可以帮助他。

输入格式:

输入的词典内容最多包含有 100 000 个词条,每一个词条包含一个英文单词,其次是一个空格和一个对应的“神族文字”。没有一个“神族文字”在词典中出现一次以上。词典词条全部输入完毕后是一个空行,之后是需要翻译的“神族文字”,每一个词一行,每个单词是一个最多为 10 个小写字母的字符串。

输出格式:

输出翻译好的英文,每行一个字。若词典中查找不到,输出“eh”。

输入实例:

dog ogday
cat atcay
pig igpay
froot ootfray
loops oopslay

atcay
igpay
oopslay

输出实例:

cat
pig
loops

 

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>

using namespace std;

inline int read(){
    int x=0,f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if( ch == - ) f=-1;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-0;
    return x*f;
}

const int maxn = 100000;

pair <string , string> dic[maxn];

int now;

int main(){
    char ch[2];
    ch[1] = \0;
    while(ch[0] = getchar()){
        if( ch[0] == \n) break;
        string a,b;
        cin>>a>>b;
        string h = ch;
        dic[now].first = h + a;
        dic[now].second = b;
        now++;
        getchar();
    }
    string a;
    while(cin>>a){
        int tmp = 1;
        for(int i = 0 ; i < now ; i ++){
            if( a == dic[i].second ){
                cout<<dic[i].first<<endl;
                tmp = 0;
            }
        }
        if(tmp ){
            puts("eh");
        }
    }
}

 

神族文字

标签:题目   int   cin   return   pac   lin   out   cstring   class   

原文地址:http://www.cnblogs.com/ysmor/p/6201118.html

(0)
(1)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!