AcWing 3204. 字符串匹配
原题链接
简单
作者:
谷心
,
2021-03-27 20:21:43
,
所有人可见
,
阅读 409
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N = 110, difference = 'A' - 'a';
char S[N],str[N][N];
int n,sense;
char changedstr[N][N];
int main()
{
scanf("%s",S);
cin >> sense >> n;
for(int i = 0;i<n;i++)
{
scanf("%s",str[i]);
};
//转化
if(!sense)
for(int j = 0; j < (int)strlen(S);j++)
if(( S[j]>='a') & (S[j]<='z')) S[j] += difference; // 统一为大写
for(int i = 0;i < n; i++)
for(int j = 0; j < (int)strlen(str[i]);j++)
if( (str[i][j]>='a') & (str[i][j]<='z') & !sense) changedstr[i][j] = str[i][j] + difference; // 统一为大写
//transform(s.begin(),s.end(),s.begin(),::toupper);
//transform(s.begin(),s.end(),s.begin(),::tolower);
else changedstr[i][j] = str[i][j];
for(int i = 0; i < n; i++)
{
string str1(S);
string str2(changedstr[i]);
if(str2.find(str1) != str2.npos) printf("%s\n",str[i] );
}
return 0;
}
%%%