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. Git初始化与上传

    一: 现在git上Create个repository 二:进入要长传的工程目录打开git bash git initgit statusgit add .//add .的时候文件不要被占用. git ...

  2. springMVC整合memcached

    非原创,文章转自:http://www.cnblogs.com/xiaoqingxin/p/4132391.html 文章我就不全copy了,摘抄下我关注的部分,想看原文的请移步上面文章链接 appl ...

  3. C# Json数据反序列化为Dictionary并根据关键字获取指定值1

    Json数据: { "dataSet": { "header": { "returnCode": "0", " ...

  4. GDI+ 绘图闪烁解决方法

    闲着没事,准备做一个类似于TeeChart的自定义控件,结果第一步的绘图就把我给难倒了,虽然早就知道GDI绘图的闪烁问题很坑,但是却没有想到如此之坑,折腾了两天,才找到解决方法. 首先在窗体加载的时候 ...

  5. redis使用watch完成秒杀抢购功能:

    redis使用watch完成秒杀抢购功能: 使用redis中两个key完成秒杀抢购功能,mywatchkey用于存储抢购数量和mywatchlist用户存储抢购列表. 它的优点如下: 1. 首先选用内 ...

  6. Linux进程间通信IPC学习笔记之同步一(线程、互斥锁和条件变量)

    基础知识: 测试代码: 参考资料: Posix 多线程程序设计

  7. mac OS X 10.9.1 配置jdk环境变量

    进入命令行 cd ~ touch .bash_profile vi .bash_profile 输入内容jdk变量配置内容: export JAVA_HOME=/Library/Java/JavaVi ...

  8. Perl内置变量速查表

    [ 文件句柄 ] $| 如果非零, 则在对当前选定的文件执行写或打印操作后强制清除缓冲区 $% 当前选中文件句柄的当前页码 $= 当前选中文件句柄的当前页面长度 $- 当前选中文件句柄的页面剩余长度 ...

  9. 使用NPIO操作Excel

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using NPOI.SS. ...

  10. Kinetic使用注意点--group

    new Group(config) 参数: config:包含所有配置项的对象. { x: "横坐标", y: "纵坐标", width: "宽度&q ...