Go to diff to previous submission
#include<iostream> #include<cstdio> #include<deque> using namespace std; int main ( void ) { int number; string error; char character; while ( cin >> number >> error ) { scanf ( "%c", &character); for ( int i = 0; i < number; i++ ) { int counter = 0; deque <char> stack; while ( 1 ) { scanf ( "%c", &character); if ( character == '\n' ) break; if ( character == error [ error . length () - 1 ] ) { stack . push_back ( character ); int index = error . length () - 1; deque<char>::iterator n; int i = 0; for ( n = stack . end (), i = ( (int) ( stack . size () ) - 1 ); n != stack . begin (); n--, i-- ) { if ( stack [i] == error [index] ) { if ( index == 0 ) { deque<char>::iterator x; for ( x = n; x <= ( n + error . length () - 1 ); x++ ) stack . erase ( x ); break; } index--; } else break; } } else stack . push_back ( character ); counter++; } if ( !counter ) { cout << endl; continue; } for ( int i = 0; i < ( int ) stack . size (); i++ ) cout << stack [i]; cout << endl; } } return ( 0 ); }
--- 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