HDU 1022 Train Problem I
2014-04-16 15:31
281 查看
栈的基本操作……
#include <cstdio> #include <cstring> #include <stack> using namespace std; char in[100],out[100]; int flag[200]; int main(){ int n,top,i,j,k,bo; while(scanf("%d",&n)!=EOF){ stack s; scanf("%s%s",&in,&out); top=i=j=k=0; bo=1; while(j<n){ if(in[i]==out[j]){ flag[k++]=0; flag[k++]=1; i++; j++; } else if((!s.empty())&&s.top()==out[j]){ flag[k++]=1; s.pop(); j++; } else if(i<n)s.push(in[i++]),flag[k++]=0; else{bo=0;break;} } if(bo==0)printf("No.\n"); else{ printf("Yes.\n"); for(int p=0;p<k;p++){ if(flag[p]==0)printf("in\n"); else printf("out\n"); } } printf("FINISH\n"); } return 0; }
相关文章推荐
- HDU 1022 Train Problem I
- HDU1022 Train Problem I
- HDU 1022 Train Problem I(栈的简单应用)
- HDU Train Problem I 1022 栈模拟
- hdu 1022 Train Problem I(stack)
- HDU1022 Train Problem I
- hdu-Train Problem I-1022
- hdu 1022 Train Problem I 解题报告
- HDU 1022 Train Problem I(用栈模拟火车出入,看能否由初始顺序到达目标顺序)
- hdu1022 Train Problem I 数据结构--栈
- hdu 1022 Train Problem I
- 【栈】hdu 1022 Train Problem I(外:poj 1383 Rails)
- HDU1022 Train Problem I
- HDU1022 Train Problem I
- Train Problem I hdu 1022 栈的运用
- 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>