该来的总会来的,gets在pat中无法进行编译,我们可以采用cin.getline,因为题目要求的是第二个肯定有输入,隐含了第一个可能没输入的情况,所以用scanf没办法接收这种情况,测试点3不通过,本题还有一个要求,即最大的几个字符没有要求,可能会导致越界
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
const int maxn=100010;
int main()
{
char str1[maxn];
char str2[maxn];
cin.getline(str1, maxn);
scanf("%s",str2);
bool hashchar[128]={false};
bool ma=false;
int len1=strlen(str1);
int len2=strlen(str2);
for (int i=0;i<len1;i++)
{
hashchar[str1[i]]=true;
if(str1[i]=='+')
ma=true;
}
for (int i=0;i<len2;i++)
{
char now=str2[i];
if(str2[i]>='A'&&str2[i]<='Z'&&ma==true)
continue;
if (str2[i]>='a'&&str2[i]<='z')
str2[i]-=32;
if (hashchar[str2[i]]==false)
printf("%c",now);
}
}