Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

my solution

Posted by frkstyc at 2005-04-23 16:01:05 on Problem 2403
In Reply To:Re:帮我找找错误 Posted by:00403022 at 2005-04-23 15:58:14
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(void)
{
	int a, b;
	string str;
	int pt, i;
	map<string, int> pts;
	cin >> a >> b;
	for(i = 0; i < a; i++)
	{
		cin >> str >> pt;
		pts[str] = pt;
	}
	for(i = 0; i < b; i++)
	{
		int total = 0;
		for(;;)
		{
			cin >> str;
			if(str == ".")
			{
				break;
			}
			map<string, int>::const_iterator ite = pts.find(str);
			if(ite != pts.end())
			{
				total += ite->second;
			}
		}
		cout << total << endl;
	}
	return 0;
}


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator