现在的位置: 首页 > 综合 > 正文

UVA 10282 Babelfish

2019年04月08日 ⁄ 综合 ⁄ 共 489字 ⁄ 字号 评论关闭

大意略。

思路:手写一个map容器即可。

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <set>
#include <map>
using namespace std;

map<string, string> Map;

char str[60];
char temp1[30], temp2[30];

void init()
{
	Map.clear();
}

void read_case()
{
	init();
	while(gets(str))
	{
		if(str[0] == '\0') break;
		sscanf(str, "%s %s", temp1, temp2);
		Map[temp2] = temp1;
	}
}

void solve()
{
	read_case();
	while(gets(str))
	{
		if(Map.find(str) != Map.end()) cout<<Map[str]<<endl;
		else cout<<"eh"<<endl;
	}
}

int main()
{
	solve();
	system("pause");
}

抱歉!评论已关闭.