C++ 字符串删除指定字符 - 算法实现
#include
using namespace std;
int main() { string str; char c;
// 输入字符串和字符
cin >> str;
cin >> c;
// 删除字符串中的所有字符c
str.erase(remove(str.begin(), str.end(), c), str.end());
// 输出删除后的字符串
cout << str << endl;
return 0;
}
原文地址: http://www.cveoy.top/t/topic/jgEE 著作权归作者所有。请勿转载和采集!