Source code for submission s849

bugs.cpp

  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7.  
  8.  
  9.  
  10.  
  11. int main(){
  12. int l;
  13. string rep, str;
  14.  
  15. while(1)
  16. {
  17. cin>>l>>rep;
  18. if(!(cin.good())) break;
  19.  
  20. size_t n=0;
  21. cin.get();
  22. for(int i=0;i<l;i++)
  23. {
  24. getline(cin,str);
  25. n=0;
  26. while(1)
  27. {
  28. n=str.find(rep,n);
  29. if(n==string::npos) break; //string::npos
  30. str.erase(n,rep.length());
  31. //n-=rep.length();
  32. //break;
  33. //if(n<0)
  34. n=0;
  35.  
  36. }
  37. cout<<str<<endl;
  38. }
  39.  
  40.  
  41.  
  42. }
  43. return 0;
  44. }
  45.