#include #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;

}

描述从键盘输入一个字符串str和一个字符c删除str中的所有字符c并输出删除后的字符串str。用c++做输入描述第一行是一个字符串; 不含空格第二行是一个字符。输出描述删除指定字符后的字符串。用例输入 1 sdf$$$sdf$$$用例输出 1 sdfsdf

原文地址: https://www.cveoy.top/t/topic/i99Y 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录