对于字符串的匹配可以用 find() 函数 ,返回的是第一次出现的下标,如果没有,则返回 -1
对于匹配大小写不同的字符串,可以先将两个串都转化为小写或者大写
将大小写字母转换成小写字母的是 tolower(c);
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
string get(string str)//把模式串和匹配串都转成小写
{
string res;
for(auto c:str)
{
res += tolower(c);//把大小写字母转换成小写
}
return res;
}
int main()
{
string s;
cin>>s;
int n,type;
cin>>type>>n;
while(n--)
{
string str;
cin>>str;
if(type && str.find(s) != -1) cout<<str<<endl;
else if(!type && get(str).find(get(s)) != -1) cout<<str<<endl;
}
return 0;
}