Go to diff to previous submission
//BUGS #include <iostream> #include <stdio.h> #include <cmath> #include <stack> using namespace std; int main(){ char arr[1000]; int n; int c; while(cin >> n){ int len = 0; cin.ignore(1); while((c=getchar()) && c!='\n' && c!=EOF){ arr[len++] = c; } arr[len] = 0; while(n-- > 0){ stack<int> s; int i = 0; while((c=getchar())){ if(i < len && c==arr[i]){ if(!s.empty()) s.pop(); s.push(i); i++; if(i==len){ s.pop(); if(!s.empty()) i=s.top()+1; else i = 0; } } else if(c==arr[0]){ i = 1; s.push(0); } else { while(!s.empty()) { i = s.top() +1; int rpos = 0; while(i--){ printf("%c", arr[rpos++]); } s.pop(); } printf("%c",c); if(c=='\n' || c==EOF) break; } } //printf("\n"); } } return 0; }
--- c4.s818.cteam039.bugs.cpp.0.main.cpp +++ c4.s891.cteam039.bugs.cpp.0.main.cpp @@ -28,5 +28,5 @@ stack<int> s; int i = 0; - while((c=getchar()) && c!='\n' && c!=EOF){ + while((c=getchar())){ if(i < len && c==arr[i]){ if(!s.empty()) s.pop(); @@ -52,10 +52,11 @@ s.pop(); } - printf("%c",c); + printf("%c",c); + if(c=='\n' || c==EOF) break; + } } - printf("\n"); - } - + //printf("\n"); + } }