C++從string中刪除所有的某個特定字符

#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define FOR(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
string str,b;
int main()
{
	getline(cin,str);
	getline(cin,b);
	for(int i=0;i<b.length();i++)
	{
		str.erase(remove(str.begin(),str.end(),b[i]),str.end());
	}
	cout<<str;
	return 0;
}

樣例

I love GPLT!  It's a fun game!
aeiou

I lv GPLT!  It's  fn gm!
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章