Go to diff to previous submission
#include <iostream> #include <algorithm> #include <string> using namespace std; int main(){ int l; string rep, str; while(1) { cin>>l>>rep; if(!(cin.good())) break; int n=0; cin.get(); for(int i=0;i<l;i++) { getline(cin,str); n=0; while(1) { n=str.find(rep,n); if(n==string::npos) break; //string::npos str.erase(n,rep.length()); n-=rep.length(); //break; if(n<0) n=0; } cout<<str<<endl; } } return 0; }
--- c4.s849.cteam042.bugs.cpp.0.bugs.cpp +++ c4.s851.cteam042.bugs.cpp.0.bugs.cpp @@ -18,5 +18,5 @@ if(!(cin.good())) break; - size_t n=0; + int n=0; cin.get(); for(int i=0;i<l;i++) @@ -29,7 +29,7 @@ if(n==string::npos) break; //string::npos str.erase(n,rep.length()); - //n-=rep.length(); + n-=rep.length(); //break; - //if(n<0) + if(n<0) n=0;