| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
基础题,不难,可是做得我想吐血~ 各种细节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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator