#45893: C++ 也有replace函式喔!!(不是只有python)


1121228@stu.wghs.tp.edu.tw (你知道我是誰嗎!!??)


#include <iostream>
#include <string>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, names;
    getline(cin, s);
    getline(cin, names);
    size_t pos = 0;
    while ((pos = names.find(s, pos)) != string::npos) {
        names.replace(pos, s.length(), "\n");
        pos += 1;
    }
    cout << names;

    return 0;
}