x2311

Untitled

Dec 21st, 2021
704
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.29 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. const string NOTICE = "abc";
  6. const string noticeON = "def";
  7. const int SIZE = 10;
  8.  
  9. bool checkString(string basicString, int i);
  10.  
  11. int main() {
  12.     string arr[SIZE]{{"abs"},
  13.                      {"abc"},
  14.                      {"avs"},
  15.                      {"dre"},
  16.                      {"qqqqqqqqqq"},
  17.                      {"deabc"},
  18.                      {"oi-abc"},
  19.                      {"trabc"},
  20.                      {"abcabc"},
  21.                      {"def"},
  22.  
  23.     };
  24.     string s = "";
  25.     for (int i = 0, g = 0; i < SIZE; ++i) {
  26.         for (int j = 0; j < arr[i].length(); j++) {
  27.             if (g != 0 || checkString(arr[i], j)) {
  28.                 if (checkString(arr[i], j))g = noticeON.length();
  29.                 else g--;
  30.                 s += noticeON[noticeON.length() - g];
  31.  
  32.                 continue;
  33.             }
  34.             s += arr[i][j];
  35.         }
  36.         arr[i] = s;
  37.         cout << endl << i << ": " << s;
  38.         s = "";
  39.         g = 0;
  40.     }
  41.  
  42. }
  43.  
  44. bool checkString(string basicString, int i) {
  45.     if (i + NOTICE.length() > SIZE) {
  46.         return false;
  47.     }
  48.     for (int j = 0; j < NOTICE.length(); j++, i++) {
  49.         if (NOTICE[j] != basicString[i]) {
  50.             return false;
  51.         }
  52.     }
  53.     return true;
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment