C++ 字符串删除指定字符
#include <iostream>
#include <string>
int main() {
std::string str;
char c;
std::cin >> str;
std::cin >> c;
std::string result = "";
for (int i = 0; i < str.length(); i++) {
if (str[i] != c) {
result += str[i];
}
}
std::cout << result << std::endl;
return 0;
}
原文地址: http://www.cveoy.top/t/topic/nIMp 著作权归作者所有。请勿转载和采集!