Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
my solutionIn 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator