思路 :
定义一个count 数组 下标为ascii码 ; count[]=1 代表 为坏键
遍历第一行输入的 坏键 , 如果是 大写字母 对应的小写字母也要标记为1 ;
接着遍历 第二行的 字符, 如果 coun[‘+’]=1 ;即如果 + 坏的话,所有的大写字母都不能输出 。
输出所有符合条件的 count[] 不为1 的即可 。
代码实现 :
#include <iostream>
#include <string.h>
#include<ctype.h>
using namespace std;
char a[100005];
char b[100005];
char c[200]={0}; // 用来标记键盘的键是否坏;
int main()
{
gets(a); // 注意这里有空格所以不要用scanf 或者cin;
gets(b);
int lena=strlen(a);
int lenb=strlen(b);
for (int j=0;j<lena ;j++ )
{
if (isupper(a[j]))
{
c[a[j]-'A'+'a']=1; // 如果是大写 对应的小写坏了 坏键存为1
}
c[a[j]]=1;
}
// 如果有'+'所有的大写字母都不能输出
int check=0;
for (int i=0;i<lenb ;i++ )
{
if(c['+']==1)
{
if(!isupper(b[i])&&c[b[i]]!=1)
{
cout<<b[i];
check=1;
}
}
else
{
if(c[b[i]]!=1)
{
cout<<b[i];
check=1;
}
}
}
if (check==0)
{
cout<<endl;
}
return 0;
}