大佬的代码超级短啊!用了string的find函数
自己写的还是略有麻烦
知识点:注意都要转换成大写字母 用函数toupper
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
using namespace std;
string a,b;
int arr[90],brr[90];
vector<char> str,ans,stru;
int main(){
cin >> a >> b;
int l = a.length();
memset(arr,-1,sizeof(arr));
memset(brr,-1,sizeof(brr));
for(int i=0; i<l; i++){
// cout << arr[a[i]-'0'] << " " << a[i] << " " << a[i]-'0' << endl;
a[i] = toupper(a[i]);
if(arr[a[i]-'0'] == -1){
str.push_back(a[i]);
arr[a[i]-'0']++;
}
}
int h = b.length();
for(int i=0; i<h; i++){
b[i] = toupper(b[i]);
if(brr[b[i]-'0'] == -1){
stru.push_back(b[i]);
brr[b[i]-'0']++;
}
}
bool key = true;
for(int i=0; i<str.size(); i++){
for(int j=0; j<stru.size(); j++){
if(str[i] == stru[j]) {
key = false;
break;
}
}
if(key) ans.push_back(str[i]);
key = true;
}
for(int i=0; i<ans.size(); i++){
cout << ans[i];
}
return 0;
}