Follows 409.c (Total 67 lines):

/* @JUDGE_ID:4461XX 409 C "string" */
/* A */
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#define MAX_N 20
#define MAX_L 20

struct Excuse{
	char text[70+1] ;
	int keynum ;
} ;

struct Excuse e[MAX_N] ;
int num_k , num_e ;
char key[MAX_N][MAX_L+1] ;

void Input( void )
{
	int i ;

	for( i=0 ; i<num_k ; ++i ) gets( key[i] ) ;
	for( i=0 ; i<num_e ; ++i ) gets( e[i].text ) ;
}
int Run( void )
{
	char tmp[70+1] , *p ;
	int i , j , n , max=0 ;

	for( i=0 ; i<num_e ; ++i ){
		strcpy( tmp , e[i].text ) ;

		for( j=0 ; tmp[j] ; ++j )
			if( !isalpha( tmp[j] ) ) tmp[j] = ' ' ;
			else tmp[j] = tolower( tmp[j] ) ;

		for( n=0,p=strtok( tmp , " " ) ; p ; p=strtok( NULL , " " ) )
			for( j=0 ; j<num_k ; ++j )
				if( !strcmp( p , key[j] ) ) ++n ;

		e[i].keynum = n ;
		max = max>n ? max : n ;
	}

	return max ;
}
void Output( int times , int n )
{
	int i ;
	
	printf( "Excuse Set #%d\n" , times ) ;
	for( i=0 ; i<num_e ; ++i )
		if( e[i].keynum==n ) puts( e[i].text ) ;
	
	putchar( '\n' ) ;
}
int main( void )
{
	int times ;
	
	for( times=1 ; scanf( "%d %d\n" , &num_k , &num_e )==2 ; ++times ){
		Input() ;
		Output( times , Run() ) ;
	}

	return 0 ;
}

Back to statistics
Ya-Lin Huang (C)
huangyl@gmail.com