问题陈述:

  杭州电子科技大学HANGZHOU DIANZI UNIVERSITY Online Judge Problem - 1022

问题解析:

  栈(stack)的简单应用

代码详解:  

 #include <iostream>
#include <cstdio>
#include <stack>
#include <cstring> using namespace std; stack<int> s; int flag[]; int main()
{
int n, i, j, k;
char o1[], o2[];
while(~scanf("%d %s%s", &n, o1, o2)){
while(!s.empty()){
s.pop();
}
memset(flag, -, sizeof(flag));
j = k = ;
for(i=; i<n; i++) {
s.push(o1[i]);
flag[k++] = ;
while(!s.empty() && s.top()==o2[j]) {
s.pop();
flag[k++] = ;
j++;
}
}
if(j == n) {
cout << "Yes." <<endl;
for(i=; i<k; i++) {
if(flag[i]) {
cout << "in" <<endl;
}else {
cout << "out" << endl;
}
}
}else {
cout << "No." << endl;
}
cout << "FINISH" << endl;
}
return ;
}

参考博客:http://blog.csdn.net/lyhvoyage/article/details/18505997

转载请注明出处:http://www.cnblogs.com/michaelwong/p/4315668.html

Train Problem I的更多相关文章

  1. hdu1032 Train Problem II (卡特兰数)

    题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能.    (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...

  2. HDU 1022 Train Problem I

    A - Train Problem I Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u ...

  3. Train Problem I 分类: HDU 2015-06-26 11:27 10人阅读 评论(0) 收藏

    Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  4. hdu 1023 Train Problem II

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1212 Train Problem II Description As we all know the ...

  5. sicily 1022. Train Problem

    本题主要是出栈入栈顺序的问题 Home Problems My Status Standing <->           1022. Train Problem     Total: 2 ...

  6. Train Problem I(栈)

    Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  7. Train Problem I--hdu1022(栈)

    Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  8. Train Problem II(卡特兰数+大数乘除)

    Train Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  9. 1023 Train Problem II(卡特兰数)

    Problem Description As we all know the Train Problem I, the boss of the Ignatius Train Station want ...

  10. train problem I (栈水题)

    杭电1002http://acm.hdu.edu.cn/showproblem.php?pid=1022 Train Problem I Time Limit: 2000/1000 MS (Java/ ...

随机推荐

  1. Array类型(一)

    1.创建数组的基本方式有两种,第一种使用Array构造函数 使用Array构造函数时可以省略new操作符 2.第二种方式是使用数组字面量表示法 由于IE的实现与其他浏览器不一致,因此我们不赞同使用这个 ...

  2. ActionSupport.getText()方法 以及 js中:<s:text name="" />

    下面略述com.opensymphony.xwork2.ActionSupport.getText()方法 public String getText(String aTextName) 说明:Get ...

  3. adb shell am pm

    adb shell am instrument [options] <COMPONENT> 作用:启动对instrument实例的监视. 参数[options]: -e <key&g ...

  4. [C++程序设计]有默认参数的函数

    实参与形参的结合是从左至右顺序进行的.因此指定默认值的参数必须放在形参表列中的最右端,否 则出错.例如: void f1(float a,int b=0,int c,char d=′a′); //不正 ...

  5. du与df为什么有时候会有差异

    以下仅为本人理解,非官方! du命令:统计父目录的目录项,若目录项存在,则进行查找 df命令:统计inode节点,根据inode节点存储的块大小进行统计 差异原因: 当一个文件被进程调用后,复制文件到 ...

  6. ubuntu14.04 安装搜狗输入法

    (1)下载链接 http://pinyin.sogou.com/linux/ (2)清除fcitx $sudo apt-get purge fcitx* (3)使用deb安装工具gdebi,这个工具能 ...

  7. 国际化标签 <fmt:bundle>&<fmt:message>的使用

    国际化标签 <fmt:bundle>&<fmt:message>的使用 Message.properties文件: name=www.gis520.com #info= ...

  8. shell脚本语法基础汇总

    shell脚本语法基础汇总 将命令的输出读入一个变量中,可以将它放入双引号中,即可保留空格和换行符(\n) out=$(cat text.txt) 输出1 2 3 out="$(cat te ...

  9. css案例学习之div+a实现菜单

    效果 代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w ...

  10. Unix/Linux环境C编程入门教程(36) 初识shell

     1.什么是Shell Shell是位为一组,依次代表文件拥有者.同组用户和其他用户的存取权限.通常文件共有3个权限,"r"表示只读:"w"表示可写:&qu ...