应该不用map,直接用ASCII码,128位:
bool hash[128];
测试点2,坏键可能没有:
用cin.getline。
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
const int maxn = 100010;
map<char, int> mp;
int main() {
char a[maxn], b[maxn];
int flag=0,tf=0;
cin.getline(a, maxn);
cin.getline(b, maxn);
int lena = strlen(a), lenb = strlen(b);
for (int i = 0; i < lena; i++)
{
if (a[i]=='+')
{
flag = 1;
}
mp[a[i]] = 1;
if (a[i] >= 'A'&&a[i] <= 'Z')
{
mp[a[i] + 32] = 1;
}
}
for (int i = 0; i < lenb; i++)
{
if (b[i] >= 'A'&&b[i] <= 'Z') {
if (mp[b[i]]==0&&flag==0)
{
cout << b[i];
tf = 1;
}
}
else
{
if (mp[b[i]] == 0)
{
cout << b[i];
tf = 1;
}
}
}
if(tf==0)cout << endl;
}