标签:detail enter runtime school new logs mis 没有 src
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 35940 Accepted Submission(s):
13552
1 #include<iostream> 2 #include<stdio.h> 3 #include<string> 4 #include<stack> 5 using namespace std; 6 int main() 7 { 8 int n; 9 stack<char> S; 10 while(scanf("%d",&n)!=EOF&&n<=9) 11 { 12 string s1,s2; 13 int j=0; 14 cin>>s1>>s2; 15 for(int i=0;i<n;i++) 16 { 17 S.push(s1[i]); 18 pd: 19 if(j<n&&!S.empty()&&S.top()==s2[j]) 20 { 21 S.pop(); 22 j++; 23 goto pd; 24 } 25 } 26 if(S.empty()) 27 { 28 cout<<"Yes."<<endl; 29 j=0; 30 for(int i=0;i<s1.length();i++) 31 { 32 S.push(s1[i]); 33 cout<<"in"<<endl; 34 ps: 35 if(j<s2.length()&&!S.empty()&&S.top()==s2[j]) 36 { 37 S.pop(); 38 j++; 39 cout<<"out"<<endl; 40 goto ps; 41 } 42 } 43 } 44 else 45 cout<<"No."<<endl; 46 cout<<"FINISH"<<endl; 47 while(!S.empty()) 48 S.pop(); 49 } 50 return 0; 51 }
代码看起来可能比较繁琐,有机会再优化一下吧。
调试了好久,但都是由于没有判断栈是否为空一直显示Runtime Error(ACCESS_VIOLATION)
标签:detail enter runtime school new logs mis 没有 src
原文地址:http://www.cnblogs.com/97-ly/p/6825984.html