Advertisement
add1ctus

Censoring

Feb 23rd, 2015
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.  
  9.     string S;
  10.     string T;
  11.     cin>>S>>T;
  12.  
  13.     size_t position;
  14.  
  15.     int ssize=S.size();
  16.     int tsize=T.size();
  17.  
  18.     for(int i=0;i<ssize-tsize;i++)
  19.     {
  20.  
  21.         bool pronajden_string=true;
  22.         for(int j=0;j<tsize;j++)
  23.             if(T[j]!=S[j+i])
  24.             {
  25.                 pronajden_string=false;
  26.                 break;
  27.             }
  28.         if(pronajden_string)
  29.         {
  30.             ssize-=tsize;
  31.             S.erase(i,tsize);
  32.             i=max(0,i-tsize);
  33.         }
  34.     }
  35.  
  36.     cout<<S;
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement