Go to diff to previous submission
#include <cstdio> #include <iostream> #include <string> using namespace std; int main (void) { string bug_str; string line_str; string s; int lines; unsigned int pozice; int start; int bug_len; while(scanf("%d", &lines) == 1) { getline(cin,bug_str); if (bug_str.length() >1 ) bug_str.erase(0,1); bug_len = bug_str.length(); for (int i = 0; i < lines; i++) { s = ""; getline(cin, line_str); s.append(line_str); start = 0; pozice = s.find(bug_str); if (pozice == string::npos) { cout << s << endl; } else { start = pozice; s.erase(start, bug_len); while (1) { pozice = s.find(bug_str,start); if (pozice == string::npos) break; start = pozice; s.erase(start, bug_len); } cout << s << endl; } } } return 0; }