/*
* 解题思路:
* 题目大意就是先给出一些单词,这些单词是不重要的,再给出一些句子,将句子中除去先前输入的不重要的单词其余单词存到一个数组中(单词不重复),排序,
* 按字典序,将重要单词数组中从第一个单词开始,分别到先前输入的句子数组中找,如果该句子中有该单词,输出该单词(除该单词大写外其他单词均小写)
* 如果一个句子中有多个该单词,则按输出例句
a MAN is a man but bubblesort is a dog a man is a MAN but bubblesort is a dog
* 这样从左到右输出该重点单词即可
* 题目没有陷阱,按题目Sample输出即可
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
char s1[ 55 ][ 11 ],s2[ 205 ][ 100 ];
char s3[ 10005 ][ 20 ];
int p,q,r;
int cmp( const void *_a , const void *_b )
{
char *a = (char *)_a;
char *b = (char *)_b;
return strcmp( a , b );
}
void Paint( int x , char temp[ ] ,int y ,int z )
{
int i;
for( i=0;i<z;i++ )
printf("%c",tolower( s2[ x ][ i ] ) );
for( i=0;i<y;i++ )
printf("%c",toupper( temp[ i ] ) );
for( i=z+y;i<strlen( s2[ x ] ) ;i++ )
printf("%c",tolower( s2[ x ][ i ] ) );
puts("");
}
void Find( int x )
{
int i,j,k;
char temp[ 20 ];
for( i=0;i<q;i++ )
{
j = 0;
while( j<strlen( s2[ i ] ) )
{
k = 0;
while( s2[ i ][ j ] != ' ' && j<strlen( s2[ i ] ) )
temp[ k++ ] = tolower( s2[ i ][ j++ ] );
temp[ k ] = '\0';
if( strcmp( s3[ x ] , temp ) == 0 )
Paint( i , temp , k , j-k );
j++;
}
}
}
void search( int x )
{
int i,j,k,o;
int flag;
char temp[ 20 ];
j = 0;
while( j< strlen( s2[ x ] ) )
{
k = 0;
while( s2[ x ][ j ] != ' ' && j < strlen( s2[ x ] ) )
temp[ k++ ] = tolower( s2[ x ][ j++ ] );
temp[ k ] = '\0';
flag = 0;
for( i=0;i<p;i++)
if( strcmp( s1[ i ] , temp ) == 0 )
{
flag = 1;
break;
}
if( !flag )
{
flag = 0;
for( o=0;o<r;o++ )
if( strcmp( s3[ o ] , temp ) == 0 )
{
flag = 1;
break;
}
if( !flag )
strcpy( s3[ r++ ] , temp );
}
j++;
}
}
int main( )
{
int i,j;
char c;
p = 0;
while( scanf("%s",&s1[ p ] ) && s1[ p ][ 0 ] != ':' ) p++;
getchar( );
q = 0;
while(( c = getchar( ) ) != EOF )
{
i = 0;
while( c!='\n' )
{
s2[ q ][ i++ ] = c;
c = getchar( );
}
s2[ q ][ i ] = '\0';
q++;
}
r = 0;
for( i=0;i<q;i++ )
search( i );
qsort( s3 , r , sizeof( s3[ 0 ] ) , cmp );
for( j=0;j<r;j++ )
Find( j );
return 0;
}