Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <iostream>
- #include <algorithm>
- using namespace std;
- void getResult(string curString, string changeSymbols, string toSymbols) {
- int i = 0;
- string tempString = "";
- string resultString = "";
- while (i < curString.length()) {
- for (int j = 0; j < changeSymbols.length(); j++) {
- tempString += curString[i + j];
- }
- if (tempString == changeSymbols) {
- resultString += toSymbols;
- i += changeSymbols.length();
- } else {
- resultString += curString[i];
- i++;
- }
- tempString = "";
- }
- cout << resultString << endl;
- }
- int main() {
- string curString;
- string changeSymbols;
- string toSymbols;
- cin >> curString >> changeSymbols >> toSymbols;
- getResult(curString, changeSymbols, toSymbols);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement