hdu 1022 Train Problem I_栈的应用经典例题
2014-07-14 16:21
501 查看
#include <iostream> #include <stack> #include <cstring> using namespace std; int main() { stack<char>s1; stack<char>s2; int n,i,j,k,a[10000]; char str1[100010],str2[100010]; while(cin>>n) { memset(str1,0,sizeof(str1)); memset(str2,0,sizeof(str2)); cin>>str1; cin>>str2; for(i=strlen(str2)-1; i>=0; i--) s2.push(str2[i]); for(i=0,j=0; i<strlen(str1); i++) { s1.push(str1[i]); a[j++]=1; while(!s1.empty()&&s1.top()==s2.top()) { s1.pop(); s2.pop(); a[j++]=0; } } if(s1.empty()&&s2.empty()) { cout<<"Yes."<<endl; for(i=0; i<2*n; i++) if(a[i]==1) cout<<"in"<<endl; else cout<<"out"<<endl; } else { cout<<"No."<<endl; while(!s1.empty()) s1.pop(); while(!s2.empty()) s2.pop(); } cout<<"FINISH"<<endl; } return 0; }
相关文章推荐
- hdu 1022 Train Problem I(栈的应用)
- hdu 1022 Train Problem I(栈的应用+STL)
- hdu 1022 Train Problem I(栈的应用。。。)
- hdu 1022 Train Problem I 【栈入门经典】
- HDU1022--Train Problem I(栈的应用)
- HDU-1022 Train Problem I (栈的简单应用)
- HDU 1022 Train Problem I(栈的简单应用)
- hdu 1022 Train Problem I (栈的应用)
- hdu 1022 Train Problem I (栈的应用)
- HDU 1022:Train Problem I(堆栈的基本应用)
- hdu-1022 Train Problem I (栈的简单应用)
- hdu 1022 Train Problem I(栈的应用+STL)
- hdu 1022 Train Problem I (栈的简单应用)
- Hdu 1022 Train Problem I (栈的简单应用)
- hdu 1022 Train Problem I 【栈入门经典】
- hdu1022 Train Problem I(STL 栈的应用)
- Train Problem I hdu 1022
- HDU 1022 ( Train Problem I )
- HDU-1022 Train Problem I
- hdu 1022 Train Problem I 模拟