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

Re:基础题,不难,可是做得我想吐血~ 各种细节

Posted by nishijj at 2011-03-31 15:04:42 on Problem 1598
In Reply To:基础题,不难,可是做得我想吐血~ 各种细节 Posted by:wjwjw at 2011-01-29 11:54:00
> MARK!
> 
> #include<iostream>
> #include<string.h>
> using namespace std;
> int main()
> {
> 	char str[70][100];
> 	int len[70];
> 	char key[25][25];
> 	int k,e;
> 	int t=0;
> 	int i,j;
> 	char temp_key[25];
> 	char temp[100];
> 	int max_len;
> 	while(scanf("%d%d",&k,&e)!=EOF)
> 	{
> 		max_len=0;
> 		for(i=0;i<k;i++)
> 			scanf("%s",key[i]);
> 		getchar();
> 		for(i=0;i<e;i++)
> 		{
> 			gets(str[i]);
> 			strcpy(temp,str[i]);
> 			len[i]=0;
> 			for(j=0;temp[j]!='\0';j++)
> 			{
> 				if (isalpha(temp[j])) {   
> 					temp[j] = tolower(temp[j]);   
> 				} else {   
> 					temp[j] = ' ';   
> 				}   
> 			}
> 			char *p=temp;
> 			while(sscanf(p,"%s",temp_key)>0)
> 			{
> 					p++;
> 				p+=strlen(temp_key);
> 				for(j=0;j<k;j++)
> 					if(strcmp(temp_key,key[j])==0)
> 						len[i]++;
> 			}
> 			if(len[i]>len[max_len])
> 				max_len=i;
> 		}
> 		printf("Excuse Set #%d\n",++t);
> 		for(i=0;i<k;i++)
> 			if(len[i]==len[max_len])
> 		printf("%s\n",str[i]);
> 			printf("\n");
> 	}
> 	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