2019-04-13
#include <stdio.h>
//转小写
char tolower( char c)
{
if( c >='A'&& c<='Z')
return c-'A'+'a';
}
//大小写敏感
bool findstr( char * instr, char * findstr)
{
char *s = instr;
char *t ;
while(1)
{
t = findstr;
while( *s != *t && *s != '\0')
s++;
if( *s == '\0')
return false;
while( *t == *s && *t != '\0' && *s !='\0')
s++,t++;
if(*t == '\0')
return true;
}
}
//大小写不敏感
bool findstr_i( char * instr, char * findstr)
{
char *s = instr;
char *t ;
while(1)
{
t = findstr;
while( tolower(*s) != tolower(*t) && *s != '\0')
s++;
if( *s == '\0')
return false;
while( tolower(*s) == tolower(*t) && *t != '\0' && *s !='\0')
s++,t++;
if(*t == '\0')
return true;
}
}
//主函数
int main()
{
char str[100];
char tarstr[100];
int count;
int flag;
int i;
scanf("%s",str);
scanf("%d",&flag);
scanf("%d",&count);
for( i = 0;i< count;i++)
{
scanf("%s",tarstr);
if( 1 == flag && findstr( tarstr, str))
printf("%s",tarstr);
if( 0 == flag && findstr_i( tarstr, str))
printf("%s",tarstr);
}
::fflush(stdin);
getchar();
return 0;
}
#include <stdio.h>
//转小写
char tolower( char c)
{
if( c >='A'&& c<='Z')
return c-'A'+'a';
}
//大小写敏感
bool findstr( char * instr, char * findstr)
{
char *s = instr;
char *t ;
while(1)
{
t = findstr;
while( *s != *t && *s != '\0')
s++;
if( *s == '\0')
return false;
while( *t == *s && *t != '\0' && *s !='\0')
s++,t++;
if(*t == '\0')
return true;
}
}
//大小写不敏感
bool findstr_i( char * instr, char * findstr)
{
char *s = instr;
char *t ;
while(1)
{
t = findstr;
while( tolower(*s) != tolower(*t) && *s != '\0')
s++;
if( *s == '\0')
return false;
while( tolower(*s) == tolower(*t) && *t != '\0' && *s !='\0')
s++,t++;
if(*t == '\0')
return true;
}
}
//主函数
int main()
{
char str[100];
char tarstr[100];
int count;
int flag;
int i;
scanf("%s",str);
scanf("%d",&flag);
scanf("%d",&count);
for( i = 0;i< count;i++)
{
scanf("%s",tarstr);
if( 1 == flag && findstr( tarstr, str))
printf("%s",tarstr);
if( 0 == flag && findstr_i( tarstr, str))
printf("%s",tarstr);
}
::fflush(stdin);
getchar();
return 0;
}