hopingsteam

Untitled

May 4th, 2020
1,787
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include    <iostream>
  2. #include    <cstring>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     char s1[100] = "ac";
  9.     char s2[500] = "ana are un ac. acum merg acasa! dar inainte voi merge la magazin de unde o sa-mi iau un_ac_si un acordeon.";
  10.     char s3[500]; strcpy(s3, s2);
  11.  
  12.     char *p = strstr(s2, s1);
  13.     while(p != NULL)
  14.     {
  15.         //cout << p << "\n";
  16.  
  17.         int c = p - s2;
  18.         if(!(p[2] >= 'a' && p[2] <= 'z'))
  19.         {
  20.             strcpy(s3+c, s3+c+strlen(s1));
  21.         }
  22.  
  23.         c += strlen(s1);
  24.         p = strstr(s2 + c, s1);
  25.     }
  26.     cout << s3;
  27.     return 0;
  28. }
RAW Paste Data