Source code for submission s1191

Go to diff to previous submission

bugs.cpp

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<deque>
  4.  
  5. using namespace std;
  6.  
  7. int main ( void )
  8. {
  9. int number;
  10. string error;
  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. deque <char> stack;
  21.  
  22. while ( 1 )
  23. {
  24. scanf ( "%c", &character);
  25. if ( character == '\n' )
  26. break;
  27.  
  28.  
  29. if ( character == error [ error . length () - 1 ] )
  30. {
  31. stack . push_back ( character );
  32. int index = error . length () - 1;
  33. deque<char>::iterator n;
  34. int i = 0;
  35. for ( n = stack . end (), i = ( (int) ( stack . size () ) - 1 ); n != stack . begin (); n--, i-- )
  36. {
  37. if ( stack [i] == error [index] )
  38. {
  39. if ( index == 0 )
  40. {
  41. deque<char>::iterator x;
  42. for ( x = n; x <= ( n + error . length () - 1 ); x++ )
  43. stack . erase ( x );
  44.  
  45. break;
  46. }
  47.  
  48. index--;
  49. }
  50. else
  51. break;
  52. }
  53.  
  54. }
  55. else
  56. stack . push_back ( character );
  57.  
  58. counter++;
  59. }
  60.  
  61. if ( !counter )
  62. {
  63. cout << endl;
  64. continue;
  65. }
  66.  
  67.  
  68. for ( int i = 0; i < ( int ) stack . size (); i++ )
  69. cout << stack [i];
  70.  
  71. cout << endl;
  72. }
  73. }
  74.  
  75. return ( 0 );
  76. }

Diff to submission s1181

bugs.cpp

--- c4.s1181.cteam017.bugs.cpp.0.bugs.cpp
+++ c4.s1191.cteam017.bugs.cpp.0.bugs.cpp
@@ -24,7 +24,5 @@
                 scanf ( "%c", &character);
                 if ( character ==  '\n' )
-                {
                     break;
-                }
                    
                 
@@ -37,8 +35,6 @@
                   for ( n = stack . end (), i = ( (int) ( stack . size () ) - 1 ); n != stack . begin (); n--, i-- )
                   {
-                      //cout << stack [i] << " " << error [index] << endl;
                       if ( stack [i] == error [index] )
                       {
-                         // cout << "shoda na " << error [index] << endl;
                           if ( index == 0 )
                           {
@@ -72,6 +68,9 @@
             for ( int i = 0; i < ( int ) stack . size (); i++ )
                 cout << stack [i];
+            
             cout << endl;
         }
     }
+    
+    return ( 0 );
 }
\ No newline at end of file