题目链接
https://pintia.cn/problem-sets/994805342720868352/problems/994805429018673152
#include<iostream>
using namespace std;
string s1,s2;
int a[200]; //利用桶来标记出现的字符
int main()
{getline(cin,s1);getline(cin,s2);int len1=s1.length();int len2=s2.length();for(int i=0;i<len2;i++){a[s2[i]]=1; //把出现的字符都标记一下}for(int i=0;i<len1;i++){if(a[s1[i]]==0) //仅输出在s2没出现的字符{cout<<s1[i];}}printf("\n");return 0;
}
#include<iostream>
using namespace std;
string s1,s2;
bool check_exists(char c)
{for(auto a:s2){if(a==c){return true;}}return false;
}
int main()
{getline(cin,s1);getline(cin,s2);string res;for(auto c:s1){if(!check_exists(c)){res+=c;}}cout<<res<<endl;return 0;
}
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
char s1[100000], s2[100000];
int main() {cin.getline(s1, 100000);cin.getline(s2, 100000);int lens1 = strlen(s1), lens2 = strlen(s2);bool flag[256] = {false};for(int i = 0; i < lens2; i++)flag[s2[i]] = true;for(int i = 0; i < lens1; i++) {if(!flag[s1[i]])printf("%c", s1[i]);}return 0;
}