Advertisement
35657

Untitled

Mar 19th, 2024
432
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5.  
  6.  
  7. int main() {
  8.     setlocale(LC_ALL, "ru");
  9.     string text = "abracadabra";
  10.     string str = "ab";
  11.     int last = text.find(str);
  12.     int longevity = str.size() + 1;
  13.     while (last != string::npos) {
  14.         text.insert(last, "(");
  15.         text.insert(last + longevity, ")");
  16.         last = text.find(str, last + longevity);
  17.     }
  18.     cout << text << endl;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement