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

太水了,注意,累计计算,贴代码。

Posted by 0943041192 at 2011-02-09 16:02:40 on Problem 2403
#include <iostream>
#include <string>

using namespace std;

struct node 
{
	long value;
	string word;
};

int main(int argc, char* argv[])
{
	string str;
	int x,y,n,i,j,sum,k,m;
	bool flag;
	cin>>m>>n;
	node *no = new node[m];
	for ( i = 0 ; i < m ; i++)
	{
		cin>>no[i].word;
		cin>>no[i].value;
	}
	while (n--)
	{
		cin>>str;
		sum = 0 ;
		while (str!=".")
		{
			for (j = 0 ; j < m ; j++)
			{
				if( no[j].word == str )
				{
					no[j].visit = true;
					sum += no[j].value;
				}
			}	
			cin>>str;
		}
		cout<<sum<<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