//----------------------------------删除公共字符------------------------------//
/*
题目描述
输入两个字符串,从第一字符串中删除第二个字符串中所有的字符。
例如,输入”They are students.”和”aeiou”,
则删除之后的第一个字符串变成”Thy r stdnts.”
输入描述:
每个测试输入包含2个字符串
输出描述:
输出删除后的字符串
示例1
输入
They are students. aeiou
输出
Thy r stdnts.
*/
//注意输入可能有空格,所以用getline,然后用了find,整体来说还是比较简单
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int f9()
{
string str, del;
getline(cin, str);
getline(cin, del);
for (auto i = str.begin(); i != str.end(); ++i)
{
auto ptr = find(del.cbegin(), del.cend(), *i);
if (ptr != del.cend())
{
str.erase(i);
--i;//注意这个条件
}
}
cout << str;
return 0;
}