zoukankan      html  css  js  c++  java
  • POJ 2503 Babelfish(map)

    题目传送门

    题目中文翻译:

    Description

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

    Input

    输入由最多100,000个字典条目组成,后面跟着一个空行,再后面跟着最多100,000个单词的消息。每个字典条目都是一个包含英文单词的行,后跟一个空格和一个外语单词。字典中同一个外语单词不会出现多次。消息是外语中的一系列单词,每行一个单词。输入中的每个单词都是最多10个小写字母的序列。

    Output

    输出是将信息翻译成英文,每行一个字。外文字词不在字典中应翻译为“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.

    解题思路:

    用map就可以水过去.

    AC代码:

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<string>
     4 #include<map>
     5 
     6 using namespace std;
     7 
     8 map<string,string> a;
     9 string l,l1,l2;
    10 char p,lk;
    11 
    12 int main() {
    13     while(true) {
    14         lk = getchar();
    15         if(lk == '
    ') break;
    16         l = lk;
    17         while(true) {
    18             p = getchar();
    19             if(p == ' ') break;
    20             l += p;
    21         }
    22         lk = getchar();
    23         l1 = lk;
    24         while(true) {
    25             p = getchar();
    26             if(p == '
    ') break;
    27             l1 += p;
    28         }
    29         a[l1] = l;
    30     }
    31     while(cin >> l2) {
    32         if(a.count(l2)) 
    33             cout << a[l2] << endl;
    34         else cout << "eh" << endl;
    35     }
    36     return 0;
    37 } 
  • 相关阅读:
    vue中使用vuepdf插件显示pdf
    vuecirclemenu漂亮的圆形菜单
    console.log输出彩色字,图片等
    项目开发之使用 maven
    用 C 扩展 python
    Flash 与 php 使用 amfphp
    纯命令行的编辑利器:用好 awk 与 sed
    远程调试Java程序
    .net core 项目文件结构浅析
    初识Redis系列之一:简单介绍
  • 原文地址:https://www.cnblogs.com/lipeiyi520/p/11146526.html
Copyright © 2011-2022 走看看