题目:
输入两个字符串,从第一字符串中删除第二个字符串中所有的字符。 例如,输入“They are students.”和”aeiou”
则删除之后的第一个字符串变成”Thy r stdnts.”
代码实现:
#include<string>
#include<iostream>
#include<vector>
using namespace std;
int main()
{
vector<string> v;
string s;//they are students
string m;//aeiou
string tmp;
getline(cin, s);//字符串一般用getline
getline(cin, m);
for (size_t i = 0; i < s.size(); i++)
{
if (m.find(s[i]) == string::npos)//npos就是-1
{
tmp += s[i];
}
}
cout << tmp;
system("pause");
return 0;
}