L1-011 A-B
本題要求你計算A−B。不過麻煩的是,A和B都是字符串 —— 即從字符串A中把字符串B所包含的字符全刪掉,剩下的字符組成的就是字符串A−B。
輸入格式:
輸入在2行中先後給出字符串A和B。兩字符串的長度都不超過10^4,並且保證每個字符串都是由可見的ASCII碼和空白字符組成,最後以換行符結束。
輸出格式:
在一行中打印出A−B的結果字符串。
輸入樣例:
I love GPLT! It’s a fun game!
aeiou
輸出樣例:
I lv GPLT! It’s fn gm!
完整代碼:
#include<bits/stdc++.h>
using namespace std;
int x[10000];
int main()
{
string a,b;
getline(cin,a);
getline(cin,b);
int lena=a.size();
int lenb=b.size();
for(int i=0;i<lenb;i++)
{
x[b[i]]=1;
}
for(int i=0;i<lena;i++)
{
if(x[a[i]]==1)
continue;
else
{
cout<<a[i];
}
}
return 0;
}
原題鏈接:
https://pintia.cn/problem-sets/994805046380707840/problems/994805130426171392