hdu 1022 Train Problem I_栈的应用经典例题
来源:互联网 发布:虚拟机ubuntu怎么联网 编辑:程序博客网 时间:2024/06/05 05:46
#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;}
0 0
- 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(栈的应用+STL)
- 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 Train Problem I 栈的基本应用
- HDU 1020 Train Problem I 栈和队列的应用
- hdu Train Problem I(栈的简单应用)
- HDU.1022 Train Problem I【栈的简单应用】(3.14)
- NoSQL & MongoDB
- css练习: 利用锚点做选取相册效果
- java语言,通过反射获得类中的字段,及对应值。
- UVa11770 - Lighting Away(排序+DFS)
- VLC命令行参数详解
- hdu 1022 Train Problem I_栈的应用经典例题
- Spring工作原理及其作用 .
- 读取Jpg和mask图片
- 挺好的图像学习博客
- iOS 的单例模式 dispatch_once
- 各种浏览器的userAgent及如何使用JS来检测游览器类型,或android是什么版本号
- PKU 3716 Panda's Birthday Present (概率问题)
- Android之WindowManager
- [ACM] POJ 1068 Parencodings(模拟)