hdu 1022 Train Problem I
2015-04-27 19:43
405 查看
栈的应用,一定要注意把栈清空啊,最近刚开始学数据结构,代码有点水,大家不要见怪
#include<iostream> #include<stack> using namespace std; int main() { int n; string in,out; stack<int>root; while(cin>>n>>in>>out) { while(root.size()) root.pop(); string re=""; for(int i=0;i<in.size();i++) { root.push(in[i]-'0'); re+='1'; while(root.size()&&root.top()==out[0]-'0') { root.pop(); out.erase(0,1); re+='2'; } } if(root.empty()) { cout<<"Yes."<<endl; for(int i=0;i<re.size();i++) { if(re[i]=='1') cout<<"in"<<endl; else cout<<"out"<<endl; } cout<<"FINISH"<<endl; } else cout<<"No."<<endl<<"FINISH"<<endl; } return 0; }
相关文章推荐
- hdu 1022 Train Problem I (栈的应用)
- HDU 1022 Train Problem I
- 杭电hdu 1022 Train Problem I 栈
- HDU 1022(Train Problem I)
- hdu1022 栈的模拟(Train Problem I)
- 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(stack)
- 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_栈的应用经典例题
- HDU 1022 Train Problem I
- HDU 1022 Train Problem I