Source code for submission s981

bugs.cpp

  1. #include<iostream>
  2. #include<cstdio>
  3.  
  4. using namespace std;
  5.  
  6. int main ( void )
  7. {
  8. int number;
  9. string error;
  10. string line;
  11. char character;
  12.  
  13. while ( cin >> number >> error )
  14. {
  15. scanf ( "%c", &character);
  16. for ( int i = 0; i < number; i++ )
  17. {
  18.  
  19. int counter = 0;
  20. line . clear ();
  21.  
  22. while ( 1 )
  23. {
  24. scanf ( "%c", &character);
  25. if ( character == '\n' )
  26. {
  27. break;
  28. }
  29.  
  30. line . push_back ( character );
  31.  
  32. counter++;
  33. }
  34.  
  35. if ( !counter )
  36. {
  37. cout << endl;
  38. continue;
  39. }
  40.  
  41. while ( 1 )
  42. {
  43. string::size_type n;
  44.  
  45. n = line . rfind ( error.c_str() );
  46. if ( n == string::npos )
  47. break;
  48.  
  49. line . erase ( n, error . length () );
  50.  
  51. }
  52. cout << line << endl;
  53. }
  54. }
  55. }