409 - Excuses, Excuses!

来源:互联网 发布:产品进入淘宝首页 编辑:程序博客网 时间:2024/05/29 08:03

#include<stdio.h>

#include<string.h>

#include<ctype.h>

#define MAXN20+5

charkeywords[MAXN][MAXN],excuses[MAXN][75];

 

intcountkey(char e[],int k)

{

      int i,j,m=0,count=0;

      char temp[75];

      for(i=0;i<k;i++)

            for (j=0;j<(int)strlen(e);j++)

            {

                  if(isalpha(e[j]))

                  {

                        temp[m]=tolower(e[j]);

                        m++;

                  }

                  else

                  {

                        temp[m]='\0';

                        m=0;

                        if(strcmp(temp,keywords[i])==0) count++;

                  }

            }

            return count;

}

 

intmain()

{

      int i,j,k,e,maxn,n[20],num=1;

      while(scanf("%d%d",&k,&e)==2)

      {

            maxn=0;

            getchar();

            for(i=0;i<k;i++)

                  scanf("%s",keywords[i]);

            getchar();

            for(i=0;i<e;i++)

                  fgets(excuses[i],75,stdin);

            for(j=0;j<e;j++)

            {

                  n[j]=countkey(excuses[j],k);

                  if(maxn<n[j]) maxn=n[j];

            }

            printf("Excuse Set #%d\n",num++);

            for(j=0;j<e;j++)

            {

                  if(n[j]==maxn)

                  {

                        printf("%s",excuses[j]);

                  }

               

            printf("\n");

         

      return 0;

}

uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=350

0 0