Go to diff to previous submission
#include <iostream> #include <cstdlib> #include <vector> #include <cstring> using namespace std; int main ( ) { int lines; string expr; while ( cin >> lines >> expr ) { cin . get(); int exprL = ( int ) expr . length(); int array[ 2000001 ]; if ( ! lines ) cout << endl; while ( lines-- ) { int cnt = 0; char ch; //start = end = array; //getline( cin, line ); int curr = 0; //memset( array, 0, sizeof( array ) ); while ( (ch = cin.get()) != '\n' ) { if ( ! cin . good() ) { ch = '\0'; break; } if(ch == expr[curr] && curr > 0) curr++; else if(ch == expr[0]) { if(curr > 0) array[cnt++] = curr; curr = 1; } else { if(cnt > 0) { for(int i = 0; i < cnt; i++) cout << expr.substr(0, array[i]); cnt = 0; }//vypiš zásobník if(curr > 0) { cout << expr.substr(0, curr); }//vypiš current cout << ch; cnt = 0; curr = 0; } if ( curr == exprL ) { if(cnt > 0) curr = array[--cnt]; else curr = 0; }//načti předchozí ze zásobníku } if(cnt > 0) { for(int i = 0; i < cnt; i++) cout << expr.substr(0, array[i]); cnt = 0; }//vypiš zásobník if(curr > 0) { cout << expr.substr(0, curr); }//vypiš current cout << endl; //printuj! } } return 0; }
--- c4.s1204.cteam011.bugs.cpp.0.bugs.cpp +++ c4.s1383.cteam011.bugs.cpp.0.bugs.cpp @@ -15,4 +15,5 @@ int exprL = ( int ) expr . length(); int array[ 2000001 ]; + if ( ! lines ) cout << endl; while ( lines-- ) { @@ -62,5 +63,5 @@ cout << expr.substr(0, curr); }//vypiš current - if ( ch == '\n' ) cout << endl; + cout << endl; //printuj! }