题目链接:http://acm.pku.edu.cn/JudgeOnline/problem?id=2403
复制代码
#include <map>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
int m,n;
map<string, int> dict;
cin >> m >>n;
int i;
string word;
int nValue;
for (i = 0; i < m; ++i)
{
cin >> word >> nValue;
dict[word] = nValue;
}
for (i = 0; i < n; ++i)
{
int sum = 0;
while (cin >> word && word != ".")
{
if (dict.find(word) != dict.end())
{
sum += dict[word];
}
}
cout << sum << endl;
}
return 0;
}
复制代码
本文转自Phinecos(洞庭散人)博客园博客,原文链接:http://www.cnblogs.com/phinecos/archive/2009/09/12/1565307.html,如需转载请自行联系原作者