#include using namespace std; // How to replace all occurrences of a character in string?. // https://stackoverflow.com/questions/2896600/how-to-replace-all-occurrences-of-a-character-in-string string replaceAll(string str, const string& from, const string& to) { size_t start_pos = 0; while((start_pos = str.find(from, start_pos)) != string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); // Handles case where 'to' is a substring of 'from' } return str; } int main() { // 1. 入力情報取得. string ans; cin >> ans; // 2. i文字目, j文字目入れ替え. ans = replaceAll(ans, "treeone", "forest"); // 3. 出力. cout << ans << endl; return 0; }