poj2503
include
include
include<stdio.h>
include<string.h>
using namespace std;
int mian()
{
char str1[35];
char key[35];
char value[35];
map<string, string> map_;
//判断输入的字符串是否为空
while (cin >> str1)
{
if (strcmp(str1, '\0') == 0)
{
break;
} //sscanf读取格式化的字符串中的数据
sscanf(str1, "%s,%s", value, key);//从一个字符串中读进与指定格式相符的数
//建立键值关系
map_.insert(make_pair(key, value));
}
while (cin >> str1)
{
map<string, string>::iterator it;//迭代器
it = map_.find(str1);//查找map中是否有此键
if (it != map_.end())
{
cout << it->second << endl;
}
else
cout << "eh" << endl;
}
return 0;
}

浙公网安备 33010602011771号