问题陈述:

  杭州电子科技大学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. <%@ include file=""%>与<jsp:include page=""/>区别

    jsp页面是把include指令元素(<%@ include file=""%>)所指定的页面的实际内容(也就是代码段)加入到引入它的jsp页面中,合成一个文件后被js ...

  2. 数字转化为人民币大写(PHP)

    <?php function numTrmb($num) { $d = array("零", "壹", "贰", "叁&qu ...

  3. git status简介

    git status命令可以列出当前目录所有还没有被git管理的文件和被git管理且被修改但还未提交(git commit)的文件.. 比如; git status # On branch maste ...

  4. LeetCode_Integer to Roman

    Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...

  5. linux系统文件夹的作用 good

    /bin 二进制可执行命令 /dev 设备特殊文件 /etc 系统管理和配置文件 如:环境变量 /etc/rc.d 启动的配置文件和脚本 /home用户主目录的基点,比如用户user的主目录就是/ho ...

  6. SQL Server索引语法 <第四篇>

    从CREATE开始 通过显式的CREATE INDEX命令 在创建约束时作为隐含的对象 随约束创建的隐含索引 当向表中添加如下两种约束之一时,就会创建隐含索引. 主键约束(聚集索引) 唯一约束(唯一索 ...

  7. Why Functional Programming Matters

    http://hi.baidu.com/lhurricane/item/35b57e12a1e3c5ddbf9042a7 http://blog.csdn.net/ddwn/article/detai ...

  8. Reverse Linked List 解答

    Question Reverse a singly linked list. Solution 1 -- Iterative Remember to set head.next = null or i ...

  9. easy ui 如何单个引用其中某个插件?

    记录一下这个方法,前端时间一直在纠结这个问题,后来听一些前辈讲解后才恍然大悟,要单独引用某个插件,我们需要重视的是:easyloaer.js ,easy ui的下载包中也有easyloader的dem ...

  10. linux下php扩展curl的安装

    方法一 安装cURL wget http://curl.haxx.se/download/curl-7.17.1.tar.gz tar -zxf curl-7.17.1.tar.gz ./config ...