ZOJ1109-map与string

本文概述了AI音视频处理领域的关键技术,包括视频分割、语义识别、自动驾驶、AR、SLAM等,并探讨了其在实际应用中的作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Language of FatMouse

Time Limit: 10 Seconds      Memory Limit: 32768 KB

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 ogday
cat atcay
pig igpay
froot ootfray
loops oopslay

atcay
ittenkay
oopslay

Output for Sample Input

cat
eh
loops


熟练掌握:
striing:  (声明:string s, char  line[size])
1.数组赋值给它的方法 s.assign(line);
2.在串中寻找字符的方法s.find(char);
3.得到子串的方法:s.substr(子字符串头,子字符串尾);也可以s.substr(子字符串头) 然后一直到串尾部。
map:
键值与映射map<string,string> m;
寻找键值 返回映射的方法!
it=m.find(temp)  *it.second;

#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;
}




评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值