Source code for submission s1238

Go to diff to previous submission

bugs2.cpp

  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. std::string BugRemover(std::string string, std::string bug_value)
  7. {
  8.  
  9. int bug_lenght = bug_value.size();
  10. int search = 1;
  11. do
  12. {
  13. search = string.find(bug_value);
  14. if( search != -1)
  15. {
  16. string.erase(search, bug_lenght);
  17. }
  18. }while(search != -1);
  19.  
  20. return(string);
  21. }
  22.  
  23. int main(void)
  24. {
  25. std::string bug;
  26. std::string input = "";
  27. std::string output = "";
  28. std::string temp;
  29. int lines;
  30. cin >> lines >> bug;
  31. for(int i = 0; i < lines; i++)
  32. {
  33. std::string tmp;
  34. cin >> tmp;
  35. temp = BugRemover(tmp,bug) + "\n";
  36. output += temp;
  37. }
  38. cout << output << endl;
  39. return(0);
  40. }
  41.  

Diff to submission s1232

bugs2.cpp

--- c4.s1232.cteam109.bugs.cpp.0.bugs2.cpp
+++ c4.s1238.cteam109.bugs.cpp.0.bugs2.cpp
@@ -36,5 +36,5 @@
                 output += temp;
         }
-        cout << endl<< output << endl;
+        cout << output << endl;
         return(0);
 }