您的位置:首页 > 其它

ZOJ 1109 Language of FatMouse

2013-04-04 23:16 381 查看
开始学习stl,准备记录下自己每天做的zoj题目。

这题用map类解起来并不困难,对字符串处理时用了substr。

题目连接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=109

#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<stdio.h>
using namespace std;

int main()
{
string s;
string s1,s2;
char c[100];
int npos;
map<string,string> fat;
map<string,string>::iterator iter;
while(gets(c)){
s.assign(c);
if(s.size()==0)
break;
npos=s.find(' ');
s1=s.substr(0,npos);
s2=s.substr(npos+1);
fat[s2]=s1;
}
while(gets(c)){
s.assign(c);
iter=fat.find(s);
if(iter!=fat.end())
cout<<fat[s]<<endl;
else
cout<<"eh"<<endl;
}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: