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 chenxuan123456789 at 2012-07-30 17:32:39 on Problem 1598
#include <stdio.h>
#include <string.h>
char keyword[70][20];
char ly[70][100];
char cha[100] = " 0123456789\".,!?~@#$%^&*(){}[]|+-;':"; 
int num[30];
int cmp(char s,char str[])
{ 
	int i,len;
	len=strlen(str);
	for(i=0;i<len;i++)
	if(s==str[i])
	return 1;
	return 0;
}
int main()
{
	int n,m,max,length,k,i,j,times=1;
	char str[100];
	while(scanf("%d %d",&n,&m)!=EOF)
	{
	getchar();
	for(i=0;i<n;i++)
	scanf("%s",keyword[i]);
    getchar();
	memset(num,0,sizeof(num));
	max=0;
	for(i=0;i<m;i++)
	{
		gets(ly[i]);
		length=strlen(ly[i]);
		char str[100];
		for(j=0;j<length;j++)
		{	
			  k=0;
			while(!cmp(ly[i][j],cha))
			{
				if(ly[i][j]>='A'&&ly[i][j]<='Z')
					str[k++]=ly[i][j]+32;
				else
                    str[k++]=ly[i][j];
				j++;
			}
			if(k>0)
			{
				str[k]='\0';
				for(int l=0;l<n;l++)
					if(!strcmp(str,keyword[l]))
						num[i]++;
			}
		}
		max=num[i]>max?num[i]:max;
	}
	printf("Excuse Set #%d\n",times++);
  	for(i=0;i<m;i++)
	if(num[i]==max)
	printf("%s\n",ly[i]);
	printf("\n");
	}
	return 1;
}

 

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