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 highspeed at 2009-12-19 09:53:16 on Problem 2403
#include<iostream>
#include<string.h>

using namespace std;

int main()
{
	int m,n;
	char kk[1000][100];
	scanf("%d %d",&m,&n);
	struct test
	{
		char key[50];
		int num;
	}t[1000];
	for(int i=0;i<m;i++)
		scanf("%s %d",t[i].key,&t[i].num);
	while(n--)
	{
		int total=0,r=0;
		while(1)
		{
            scanf("%s",kk[r++]);
            if(strcmp(kk[r-1],".")==0)
			{
				printf("%d\n",total);
				break;
			}
			else 
				for(int i=0;i<m;i++)
					if(strcmp(kk[r-1],t[i].key)==0)
						total+=t[i].num;
		}
	}
}

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