Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- const string NOTICE = "abc";
- const string noticeON = "def";
- const int SIZE = 10;
- bool checkString(string basicString, int i);
- int main() {
- string arr[SIZE]{{"abs"},
- {"abc"},
- {"avs"},
- {"dre"},
- {"qqqqqqqqqq"},
- {"deabc"},
- {"oi-abc"},
- {"trabc"},
- {"abcabc"},
- {"def"},
- };
- string s = "";
- for (int i = 0, g = 0; i < SIZE; ++i) {
- for (int j = 0; j < arr[i].length(); j++) {
- if (g != 0 || checkString(arr[i], j)) {
- if (checkString(arr[i], j))g = noticeON.length();
- else g--;
- s += noticeON[noticeON.length() - g];
- continue;
- }
- s += arr[i][j];
- }
- arr[i] = s;
- cout << endl << i << ": " << s;
- s = "";
- g = 0;
- }
- }
- bool checkString(string basicString, int i) {
- if (i + NOTICE.length() > SIZE) {
- return false;
- }
- for (int j = 0; j < NOTICE.length(); j++, i++) {
- if (NOTICE[j] != basicString[i]) {
- return false;
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment