409-Excuses, Excuses!

#include<stdio.h> #include<string.h> #include<ctype.h> #define LOCAL char word[22][22]; char excuse[22][75]; char s[22]; int num[22]; int main() { #ifdef LOCAL freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif LOCAL int k,e; int i,j,t,max,p,count=0; scanf("%d%d",&k,&e); while(scanf("%d %d",&k,&e)!=EOF) { count++; max=0; for(i=0;i<k;i++) scanf("%s",word[i]); getchar(); for(i=0;i<e;i++) gets(excuse[i]); memset(s,'/0',sizeof(s)); memset(num,0,sizeof(num)); for(i=0;i<e;i++) { int len=strlen(excuse[i]); p=0; for(j=0;j<len;j++) { while(isalpha(excuse[i][j])) { s[p++]=tolower(excuse[i][j]); j++; } if(p!=0) { for(t=0;t<k;t++) if(strcmp(s,word[t])==0) num[i]++; p=0; memset(s,'/0',sizeof(s)); } } if(num[i]>max) max=num[i]; } printf("Excuse Set #%d/n",count); for(i=0;i<e;i++) if(num[i]==max) printf("%s/n",excuse[i]); printf("/n"); } return 0; }

你可能感兴趣的:(409-Excuses, Excuses!)