博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UVA 10282 (13.08.18)
阅读量:6154 次
发布时间:2019-06-21

本文共 1387 字,大约阅读时间需要 4 分钟。

Problem C: Babelfish

You have just moved from Waterloo to a big city. The people here speakan incomprehensible dialect of a foreign language. Fortunately, you havea dictionary to help you understand them.

Input consists of up to 100,000 dictionary entries, followed by a blankline, followed by a message of up to 100,000 words. Each dictionaryentry is a line containing an English word, followed by a space and aforeign language word. No foreign word appears more than once in thedictionary. 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 10lowercase letters.Output is the message translated to English, one word per line. Foreignwords not in the dictionary should be translated as "eh".

Sample Input

dog ogdaycat atcaypig igpayfroot ootfrayloops oopslayatcayittenkayoopslay

Output for Sample Input

catehloops

题意: 这么短的题目还用我解释?

解法: 按出题者意思是要用哈希算法, 但是可用STL中的map

AC代码:

 

#include
#include
#include
#include
using namespace std;char str1[30];char str2[30];char str[50];map
Map;int main() { Map.clear(); while(gets(str) != NULL) { if(str[0] == '\0') break; sscanf(str, "%s %s", str1, str2); Map[str2] = str1; } while(scanf("%s", str) != EOF) { if(Map.find(str) != Map.end()) cout<< Map[str] <

 

 

转载地址:http://jsbfa.baihongyu.com/

你可能感兴趣的文章
爬虫豆瓣top250项目-开发文档
查看>>
有趣的数学书籍
查看>>
teamviewer 卸载干净
查看>>
eclipse的maven、Scala环境搭建
查看>>
架构师之路(一)- 什么是软件架构
查看>>
USACO 土地购买
查看>>
【原创】远景能源面试--一面
查看>>
B1010.一元多项式求导(25)
查看>>
10、程序员和编译器之间的关系
查看>>
配置 RAILS FOR JRUBY1.7.4
查看>>
AndroidStudio中导入SlidingMenu报错解决方案
查看>>
修改GRUB2背景图片
查看>>
Ajax异步
查看>>
好记性不如烂笔杆-android学习笔记<十六> switcher和gallery
查看>>
JAVA GC
查看>>
3springboot:springboot配置文件(外部配置加载顺序、自动配置原理,@Conditional)
查看>>
前端第七天
查看>>
图解SSH原理及两种登录方法
查看>>
【总结整理】JQuery基础学习---样式篇
查看>>
查询个人站点的文章、分类和标签查询
查看>>