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

WA了N+次,求助...

Posted by bigheadghost at 2007-02-05 00:53:30 on Problem 2403
//WA CODE
#include<cstdio>
#include<string>
int n,m,s[1001];
char dict[1001][17],desc[10000000];
int main()
{
	scanf("%d%d",&m,&n);
	int i,j;	
	for(i=0;i<m;i++)
		scanf("%s%d",dict[i],&s[i]);
	gets(desc);
	for(i=0;i<n;i++)
	{
		int sum=0;
		while(gets(desc) && strcmp(desc,"."))
		{
			for(j=0;j<m;j++)
			{
				char * p=desc;
				int len=strlen(dict[j]);
				while(p=strstr(p,dict[j]))
				{
					sum+=s[j];
					p+=len;					
				}
			}
		}
		printf("%d\n",sum);
	}
	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