#include<iostream> #include<string> #include<vector> using namespace std; int main() { string sentence, target_str, replace_str; getline(cin, sentence); getline(cin, target_str); getline(cin, replace_str); sentence = sentence + " "; vector<string>words; string temp_str = ""; for (int i = 0; i < (int)sentence.size(); i++) { if (sentence[i] != ' ') { temp_str = temp_str + sentence[i]; } else { words.push_back(temp_str); temp_str = ""; } } for (auto iter = words.begin(); iter != words.end(); iter++) { if ((*iter) != target_str) { cout << *iter << " "; } else { cout << replace_str << " "; } } }