Source code for submission s1179

Go to diff to previous submission

bugs.cpp

  1. #include <iostream>
  2. #include <string>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. string line, bug;
  9. int T;
  10. size_t pos;
  11.  
  12. while (cin >> T)
  13. {
  14. cin >> bug;
  15. cin.ignore();
  16. for ( ; T; T--)
  17. {
  18. pos = 0;
  19. getline(cin, line);
  20. while ((pos = line.find(bug, pos)) != string::npos)
  21. {
  22. line.erase(pos, bug.length());
  23. pos = pos - bug.length();
  24. pos = (pos < 0) ? 0 : pos;
  25. }
  26. cout << line << endl;
  27. }
  28. }
  29.  
  30. return 0;
  31. }
  32.  

Diff to submission s1126

bugs.cpp