/*
* 解题思路:
* 这是道非常坑爹的题目、开始一直Runtime error、不知道为什么、后来发现是再输入的时候
* My dog ate my homework.
* Can you believe my dog died after eating my canary... AND MY HOMEWORK?
* This excuse is so good that it contain 0 keywords.
* 最后一行系统没有换行、不能单单通过判断 ‘\n’ 来停止输入( 这仅对前两行有效 ),还应增加EOF来停止最后一行输入、
* 否则系统一直认为你没有输入完全、进入死循环,导致Runtime error的错误!!
*/
#include <stdio.h> #include <string.h> #define A 30 #define B 100 int m,n; char s[ A ][ B ],str[ A ][ B ],ss[B ]; char convert( char x ) { if( x<=‘z‘ && x>=‘a‘ ) return x-‘a‘+‘A‘; if( x<=‘Z‘ && x>=‘A‘ ) return x-‘A‘+‘a‘; } int search( ) { int i,j; int flag,len; len = strlen( ss ); for( i=0;i<m;i++ ) { j = flag = 0; while( j<len ) { if( s[ i ][ j ] == ss[ j ] || s[ i ][ j ] == convert( ss[ j ] ) ) j++; else { flag = 1; break; } } if( !flag && s[ i ][ j ] == ‘\0‘) break; } if( flag ) return 0; else return 1; } int main( ) { int i,j; int p,q,r,x,sum,total,maxSum; int len[ A ],maxPos[ A ]; char c; total = 1; while( ~scanf("%d%d",&m,&n) ) { for( i=0;i<m;i++ ) { getchar(); scanf("%s",&s[ i ] ); } getchar( ); maxSum = 0; for( i=0;i<n;i++ ) { p = 0; while(( c = getchar( )) !=‘\n‘ && c != EOF ) str[ i ][ p++ ] = c; len[ i ] = p; } maxSum = q = 0; for( i=0;i<n;i++ ) { p = sum = r = 0; while( p<len[ i ] ) { if( !((str[ i ][ p ]<=‘z‘ && str[ i ][ p ] >=‘a‘ ) || (str[ i ][ p ] <=‘Z‘ && str[ i ][ p ]>=‘A‘ ) )) { p++; continue; } while( (str[ i ][ p ]<=‘z‘ && str[ i ][ p ] >=‘a‘ ) || (str[ i ][ p ] <=‘Z‘ && str[ i ][ p ]>=‘A‘ ) ) ss[ r++ ] = str[ i ][ p++ ]; x = search( ); if( x ) sum++; p++; r = 0; memset(ss,‘\0‘,sizeof( ss ) ); } if( sum > maxSum ) { q = 0; maxSum = sum; maxPos[ q ] = i; } else if( sum == maxSum ) maxPos[ ++q ] = i; } printf("Excuse Set #%d",total++ ); for( i=0;i<=q;i++ ) for( puts(""),j=0;j<len[ maxPos[ i ] ];j++ ) printf("%c",str[ maxPos[ i ] ][ j ]); puts(""); puts(""); } return 0; }