题目链接:7-29 删除字符串中的子串
一. 题目
1. 题目

2. 输入输出样例

3. 限制

二、代码(python)
1. 代码实现
str1 = input().split('\n')[0]
str2 = input().split('\n')[0]
while str2 in str1:
  str1 = str1.replace(str2, "") // 删除子串
print(str1)
2. 提交结果

三、代码(c++)
1. 代码实现
#include <iostream>
#include <string>
using namespace std;
int main(void) {
    string s1, s2;
    size_t len2, pos;
    getline (cin, s1); //按行获取输入
    getline (cin, s2);
    len2 = s2.length();
    pos = s1.find(s2);
    while (pos != -1) {
        s1 = s1.erase (pos, len2); // 删除子串
        pos = s1.find(s2);
    }
    cout << s1 << endl;
    return 0;
}
2. 提交结果




















