正确代码
#include <iostream>
#include <string>
using namespace std;
string str;
int isupper(char c){
if(c >= 'A' && c <= 'Z') return 1;
else return 0;
}
int islower(char c){
if(c >= 'a' && c <= 'z') return 1;
else return 0;
}
char toupper(char c){
return (c-'a'+'A');
}
int main(){
//freopen("C:\\Users\\pc\\Desktop\\use.txt","r",stdin);
string str1,str2;
getline(cin, str1);
getline(cin, str2);
int flag = 0; //大写键坏了为1
for(int i = 0;i < str1.length();++i){
if(str1.find('+') != -1) flag = 1;
}
//int n = upper(str1[0]);
int n = str1.find('I');//找得到就返回位置 !=-1 不输
for(int i = 0;i < str2.length();++i){
if(flag == 1 && (isupper(str2[i]))) continue;
if(islower(str2[i])){
if(str1.find(toupper(str2[i])) != -1) continue;
if(str1.find(str2[i]) != -1) continue;
}
if((str1.find(str2[i]) != -1)) continue;
printf("%c",str2[i]);
}
//for(int t = 0;t<i;++t) printf("%d\n",s[t]);
return 0;
}
注:测试点2通不过,输入不要用cin
学习别人的写法
写法1:(出处https://blog.csdn.net/missxy_/article/details/86484523)
find() != string::npos说明查找没有匹配