POJ 2503-Babelfish(map)
2024-10-22 08:44:22
题目地址:POJ 2503
题意:输入一个字典。字典格式为“英语 外语”的一一映射关系然后输入若干个外语单词。输出他们的 英语翻译单词,假设字典中不存在这个单词,则输出“eh”。
思路:用map存取外语和英语的映射关系,然后找就好了。注意输入格式。
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <map>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
typedef __int64 LL;
const int inf=0x3f3f3f3f;
const double pi= acos(-1.0);
const double esp=1e-7;
map<string,string>mp;
char str1[110],str2[110],str[110];
int main()
{
int n;
mp.clear();
while(1){
gets(str);
if(!strcmp(str,"")) break;
sscanf(str,"%s%s",str1,str2);
mp[str2]=str1;
}
while(~scanf("%s",str)){
if(mp.find(str)==mp.end())
puts("eh");
else
printf("%s\n",mp[str].c_str());//c_str是直接返回一个以/0结尾的字符串,仅仅能使用一次。
}
return 0;
}
$(function () {
$('pre.prettyprint code').each(func
最新文章
- Android架构:用消息机制获取网络数据
- hduoj 4707 Pet 2013 ACM/ICPC Asia Regional Online —— Warmup
- Win异常: 除了chrome浏览器外,所有安装的软件都连不上网
- [Powershell] FTP Download File
- Chapter 1 Securing Your Server and Network(5):使用SSL加密会话
- MIP 技术进展月报:储存功能全新上线,MIP-Cache域名升级,校验更严谨
- tomcat7启动闪退
- content-box和border-box
- Django(框架、模板)
- Bitbox : a small open, DIY 32 bit VGA console
- log4j MDC用户操作日志追踪配置
- Packet for query is too large (5,145 >; 1,024). You can change this value on the server by setting the &#39;max_allowed_packet&#39; variable.
- BufferedInputStream 缓冲输入字节流 -------上
- 南昌邀请赛网络赛 D.Match Stick Game(dp)
- 推进";五通一平";:手淘技术";三大容器 五大方案";首次整体亮相 百川开放升级
- angular学习笔记(九)-css类和样式3
- centos 安装php扩展的两种方法
- 东东糖博客MYSQL
- 一个jquery-ajax post例子ajax 登陆
- 《锋利的JQuery》读书要点笔记2——DOM操作
热门文章
- Codeforces Round #352 (Div. 2) C
- js加解密的算法
- xmlSerializer属性的使用
- DataTable 去重合并
- (转)MSI - Enable MSI Logging
- vmware上搭建kickstart 网络安装centos6.2的过程
- springBoot Ribbon Hystrix
- App接口加密解密方法
- Codeforces Round #446 (Div. 2) A. Greed【模拟】
- Python的网络编程[2] ->; TFTP 协议[1] ->; TFTP 的 Python 实现