ZOJ1109-map与string
来源:互联网 发布:欧洲 旅游 大学生 知乎 编辑:程序博客网 时间:2024/05/17 06:28
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 Specification
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 Specification
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 ogdaycat atcaypig igpayfroot ootfrayloops oopslayatcayittenkayoopslay
Output for Sample Input
catehloops
#include<cstdio>#include<iostream>#include<map>#include<string>using namespace std;map<string,string>m;int main(){string a,b,s;char line[100];while(true){int pos;gets(line); //因为cin不能吸收空行, 所以只能用gets();s.assign(line); //记住这个赋值方法if(s.empty()) break;pos=s.find(' ');a=s.substr(0,pos); //注意这个得到字串的方法。b=s.substr(pos+1);m[b]=a;}string temp;map<string,string>::iterator it;while(cin>>temp){if(m.find(temp)!=m.end()){it=m.find(temp);cout<<(*it).second<<endl;}else cout<<"eh"<<endl;}return 0;}
- ZOJ1109-map与string
- 传Map与传String
- [水]ZOJ1109
- javaBean与Map<String,Object>互转
- javaBean与Map<String,Object>互转 .
- javaBean与Map<String,Object>互转
- javaBean与Map<String,Object>互转
- javaBean与Map<String,Object>互转
- javaBean与Map<String,Object>互转
- javaBean与Map<String,Object>互转
- javaBean与Map<String,Object>互转
- javaBean与Map<String,Object>互转
- javaBean与Map<String,Object>互转
- javaBean与Map<String,Object>相互转换
- ZOJ1109 Language of FatMouse
- ZOJ1109 Language of FatMouse
- Map.Entry<String,String>
- c++ map<string,string>
- emgu cv 在WPF上显示图像
- Silverlight 之 image source 绑定
- 感谢他们,但除了感谢我实在不可能对他们有其他的感觉了,就像我
- Asp.Net MVC 路由
- ios开发适配3.5寸和4寸屏幕
- ZOJ1109-map与string
- POJ 2019 Cornfields (二维RMQ,3级)
- Linux 下编译、安装、配置 QT
- 定时器的比较
- HDU 4456 Crowd 坐标旋转 二维树状数组
- 更改Eclipse的Title标题/标题图标/启动画面/帮助信息
- CentOS Linux自动备份MySQL数据库到远程FTP服务器并删除指定日期
- mac上使用版本管理器之github
- boost库中thread多线程详解1