Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <string>
  2. #include <iostream>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. void getResult(string curString, string changeSymbols, string toSymbols) {
  7.     int i = 0;
  8.     string tempString = "";
  9.     string resultString = "";
  10.     while (i < curString.length()) {
  11.         for (int j = 0; j < changeSymbols.length(); j++) {
  12.             tempString += curString[i + j];
  13.         }
  14.         if (tempString == changeSymbols) {
  15.             resultString += toSymbols;
  16.             i += changeSymbols.length();
  17.         } else {
  18.             resultString += curString[i];
  19.             i++;
  20.         }
  21.         tempString = "";
  22.     }
  23.     cout << resultString << endl;
  24. }
  25.  
  26. int main() {
  27.  
  28.     string curString;
  29.     string changeSymbols;
  30.     string toSymbols;
  31.  
  32.     cin >> curString >> changeSymbols >> toSymbols;
  33.  
  34.     getResult(curString, changeSymbols, toSymbols);
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement