#include <iostream>
#include <string>
using namespace std;
void getStr(const string &sub, string &src) {
int l1 = src.size();
int l2 = sub.size();
for (int i = 0; i < l1; ) {
if (sub == src.substr(i, l2)) {
src = src.substr(0, i) + src.substr(i+l2);
l1 = src.size();
}
else {
i++;
}
}
}
int main() {
string str, temp;
cin >> str;
cin >> temp;
getStr(str, temp);
cout << str;
return 0;
}
0、删除源字符串中的所有指定字串,并输出删除后的字符串
于 2023-01-31 21:44:48 首次发布