Babelfish

Description
You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.
Input
Input consists of up to 100,000 dictionary entries, followed by a blank line, followed by a message of up to 100,000 words. Each dictionary entry is a line containing an English word, followed by a space and a foreign language word. No foreign word appears more than once in the dictionary. The message is a sequence of words in the foreign language, 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. Foreign 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

题目大意:

    一本猫与人类语言的翻译字典,输入一个猫的语言,输出人的语言,若没有输出eh。

解题思路:

    map映射水过。

Code:

 /*************************************************************************
> File Name: poj2503.cpp
> Author: Enumz
> Mail: 369372123@qq.com
> Created Time: 2014年10月19日 星期日 16时54分07秒
************************************************************************/ #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<list>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#define MAXN 100000
using namespace std;
map <string,string> m;
void Solve()
{
char tmp1[];
string str1,str2;
while (gets(tmp1)&&strlen(tmp1))
{
int k=;
str1=str2="";
while ()
if (tmp1[k]==' ')
{
tmp1[k]='\0';
break;
}
else k++;
str1+=tmp1;
str2+=tmp1+k+;
m[str2]=str1;
}
while (cin>>str1)
if (m[str1].size())
cout<<m[str1]<<endl;
else
cout<<"eh"<<endl;
return ;
}
int main()
{
Solve();
return ;
}

POJ2503——Babelfish(map映射+string字符串)的更多相关文章

  1. POJ2503 Babelfish map或者hash_map

    POJ2503 这是一道水题,用Map轻松AC. 不过,可以拿来测一下字符串散列, 毕竟,很多情况下map无法解决的映射问题需要用到字符串散列. 自己生成一个质数, 随便搞一下. #include&l ...

  2. Java Map获取key和value 以及String字符串转List方法

    一.问题描述 这里描述两个问题: 1.Java Map获取key和value的方法: 2.String字符串转List的方法: 二.解决方法 1.Java Map获取key和value的方法   2. ...

  3. Map 集合 和 String 字符串相互转换工具类

    package com.skynet.rimp.common.utils.util; import java.util.Arrays; import java.util.HashMap; import ...

  4. hdu 1075 map的使用 字符串截取的常用手段 以及string getline 使用起来的注意事项

    首先说字符串的截取套路吧 用坐标一个一个的输入 用遍历的方式逐个去检查字符串中的字符是否为符合的情况 如果是的话 把该字符放入截取string 中 让后坐标前移 如果不是的话 截取结束 坐标初始化 然 ...

  5. fastjson在将Map<Integer, String>转换成JSON字符串时,出现中文乱码问题

    fastjson在将Map<Integer, String>转换成JSON字符串时,出现中文乱码问题. 先记下这个坑,改天在看看是怎么导致的,暂时通过避免使用Integer作为键(使用St ...

  6. poj_2503(map映射)

    题目链接poj2503 Babelfish Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 38820   Accepted: ...

  7. map——映射(message.cpp)

    信息交换 (message.cpp) [题目描述] Byteland战火又起,农夫John派他的奶牛潜入敌国获取情报信息. Cow历尽千辛万苦终于将敌国的编码规则总结如下: 1 编码是由大写字母组成的 ...

  8. Java精选笔记_集合【Map(映射)接口】

    Map(映射)接口 简介 该集合存储键值对,一对一对的往里存,并且键是唯一的.要保证map集合中键的唯一性. 从Map集合中访问元素时,只要指定了Key,就能找到对应的Value. 关键字是以后用于检 ...

  9. Chat Order (map映射)

     Chat Order Time Limit:3000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit ...

随机推荐

  1. poj 1077 Eight(A*)

    经典的八数码问题,用来练习各种搜索=_=.这题我用的A*做的,A*的主要思想就是在广搜的时候加了一个估价函数,用来评估此状态距离最终状态的大概距离.这样就可以省下很多状态不用搜索.对于每个状态设置一个 ...

  2. 解决Scala异常处理java.lang.OutOfMemoryError: Java heap space error

    需求:百万.千万.4千万级日志对设备进行除重环境:设备内存64G,scala单机版运行shell文件日志:20G 48000000.log4.0G 10000000.log396M 1000000.l ...

  3. c++,C# 转换

    //C++中的DLL函数原型为        //extern "C" __declspec(dllexport) bool 方法名一(const char* 变量名1, unsi ...

  4. Android Activity 注意笔记

    图1:Activity生命周期的简化图,就像一个阶梯金字塔.这图像表明每个状态中是怎么样使用回调函数使得恢复状态回到顶端,或者降低状态到达底部.Activity可以从Paused状态和stopped状 ...

  5. PHP MYSQL 数据库配置连接

    //配置文件 Config.php // 默认使用数据库配置 ***************************************** $Config['ConnectTag'] = 'de ...

  6. Spark Tungsten揭秘 Day2 Tungsten-sort Based Shuffle

    Spark Tungsten揭秘 Day2 Tungsten-sort Based Shuffle 今天在对钨丝计划思考的基础上,讲解下基于Tungsten的shuffle. 首先解释下概念,Tung ...

  7. HTMLParser获取属性名

    HTMLParser获取属性名方式: 原始网页文本: <a title="美军被曝虐尸" href="http://www.sogou.com/web?query= ...

  8. sql with递归

       with temp as ( select Id, UserId, OfficeID, RoleId, DeptId, IsDelete, IsEnd, ParentId from [dbo]. ...

  9. 监控SQL Server的job执行情况

    在服务器没有设置发邮件并且不允许发邮件的情况下, 可以通过下列语句来检查SQL Server 的job的执行情况 select top 150 a.run_date,a.run_time, b.nam ...

  10. iPhone手机屏幕的尺寸

    以下是 iPhone的型号和对应的屏幕宽高 英寸  宽 高  厚度 3.5   320 480 4s      ipad   系列   4   320 568 5   5s   4.7  375 66 ...