其他语言

本类阅读TOP10

·基于Solaris 开发环境的整体构思
·使用AutoMake轻松生成Makefile
·BCB数据库图像保存技术
·GNU中的Makefile
·射频芯片nRF401天线设计的分析
·iframe 的自适应高度
·BCB之Socket通信
·软件企业如何实施CMM
·入门系列--OpenGL最简单的入门
·WIN95中日志钩子(JournalRecord Hook)的使用

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
浙大在线评测 1109 Language of FatMouse

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

Problem:

    We all know that FatMouse doesn't speak English. But now he has to be prepared since our nation will join WTO soon. Thanks to Turing we have computers to help him.


Input:

    Input consists of up to 100,005 dictionary entries, followed by a blank line, followed by a message of up to 100,005 words. Each dictionary entry is a line containing an English word, followed by a space and a FatMouse word. No FatMouse word appears more than once in the dictionary. The message is a sequence of words in the language of FatMouse, 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. FatMouse 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


Solution:

#include <iostream>
#include <string>
#include <map>
using namespace std;

// 声明:本代码仅供学习之用,请不要作为个人的成绩提交。
// http://blog.csdn.net/mskia
// email: [email protected]

int main( void ) {

    map< string , string > dic;
    map< string , string >::iterator p;
   
    string eword , mword;
    while ( cin >> eword ) {
        int len = eword.size( );
        if ( eword[ len - 2 ] == 'a' && eword[ len - 1 ] == 'y' ) {
            break;
        }
       
        cin >> mword;
        dic.insert( pair< string , string >( mword , eword ) );
    }
   
    mword = eword;
    do {
        p = dic.find( mword );
        if ( p == dic.end( ) ) {
            cout << "eh" << endl;
        } else {
            cout << p->second << endl;
        }
    } while ( cin >> mword );


    return 0;
}




相关文章

相关软件