HDU1022数据结构题目,为什么总是错?
//暂时错误#include<cstdio>#include<stack>#include<queue>#include<string>#include<iostream>using namespace std;int main(){ stack<char> s; queue<string> q; char s1[110],s2[110]; int n; while(scanf("%d",&n)!= EOF) { //getchar(); if(!s.empty()) s.pop(); if(!q.empty()) q.pop(); scanf("%s%s",s1,s2); //cout<<strlen(s1)<<endl; //printf("%s\n%s",s1,s2); int k=0; int i=0; while(i<=n) { if(!s.empty()&&s.top()==s2[k]) { while(!s.empty()&&s.top()==s2[k]) { s.pop(); q.push("out"); k++; } if(k>=n) break; //i--; } else if(i==n) break; else { s.push(s1[i]); q.push("in"); i++; } } if(k>=n) { puts("Yes."); while(!q.empty()) { cout<<q.front()<<endl; q.pop(); } } else puts("No."); puts("FINISH"); } return 0;}