Advertisement
Spocoman

07. Replace All

Oct 29th, 2023 (edited)
1,302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     string str, oldStr, newStr;
  8.     getline(cin, str);
  9.     getline(cin, oldStr);
  10.     getline(cin, newStr);
  11.  
  12.     while (str.find(oldStr) != -1) {
  13.         str.replace(str.find(oldStr), oldStr.length(), newStr);
  14.     }
  15.  
  16.     cout << str << endl;
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement