Advertisement
STANAANDREY

IMP pb1 10/16/2019

Oct 16th, 2019
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <stdio.h>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     char s[256], c1[22], c2[22], *p, aux[22];
  9.     gets(s);
  10.     cin >> c1 >> c2;
  11.     int n1 = strlen(c1);
  12.     p = strstr(s, c1);
  13.     while (p)
  14.     {
  15.         strcpy(aux, c2);
  16.         strcat(aux, p + n1);
  17.         strcpy(p, aux);
  18.         p = strstr(s + 1, c1);
  19.     }
  20.  
  21.     puts(s);
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement