做题思路必须很清晰啊....可以用数组存储in或out来着,第一次C++用string啊,效果还行

Problem : 1022 ( Train Problem I )     Judge Status : Accepted
RunId : 10418893 Language : C++ Author : mnmlist
Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta
#include<iostream>
#include<string>
#include<stack>
using namespace std;
string isRight(int x,int *a,int *b);
int main()
{
int x,y,z;
int a[10],b[10]; while(cin>>x>>y>>z)
{
string str="";
for(int l=x;l>0;l--)
{
a[l]=y%10;y/=10;
b[l]=z%10;z/=10;
}
str=isRight(x,a,b);
cout<<str; }
return 0;
}
string isRight(int x,int *a,int *b)
{
string str="";
stack<int>st;
int i=1,j=1;
while(i<2*x)
{
if(i<=x)
{
st.push(a[i]);
str+="in\n";
}
while(j<=x&&!st.empty()&&st.top()==b[j])
{
st.pop();
str+="out\n";
j++;
}
i++;
}
if(st.empty())
str="Yes.\n"+str;
else
str="No.\n";
str+="FINISH\n";
return str;
}

Problem : 1022 ( Train Problem I )的更多相关文章

  1. sicily 1022. Train Problem

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

  2. HDU 1022 Train Problem I(栈的操作规则)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1022 Train Problem I Time Limit: 2000/1000 MS (Java/Ot ...

  3. HDU 1022 Train Problem I

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

  4. (hdu)1022 Train Problem I 火车进站问题

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1022 Problem Description As the new term comes, ...

  5. hdu 1022 Train Problem I【模拟出入栈】

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

  6. HDU 1022 Train Problem I(栈模拟)

    传送门 Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot of st ...

  7. HDOJ/HDU 1022 Train Problem I(模拟栈)

    Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot o ...

  8. Hdu 1022 Train Problem I 栈

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

  9. HDU 1022.Train Problem I【栈的应用】【8月19】

    Train Problem I Problem Description As the new term comes, the Ignatius Train Station is very busy n ...

随机推荐

  1. idea 打开自动编译以及查看Problem窗口

    1.打开perference 2.选择Build-Compile-Make Project Automatically自动构建项目

  2. Shell 编程入门

    首先创建一个文件: 在终端中输入如下命令: vi helloworld.sh 然后按i进行命令编写 下面这句话是必须写的 #!/bin/sh这句话是必须写的 #!/bin/sh a="hel ...

  3. .addClass(),.removeClass(),.toggleClass()的区别

    .addClass("className")方法是用来给指定元素增加类名,也就是说给指定的元素追加样式: 可以同时添加多个类名,空格符隔开 $("selector&quo ...

  4. MyCat 读写分离,负载均衡

    docker mysql 主从复制 配合Spring 事务 注意事项 配置好JRE,安装好MYCAT 在mysql主库创建表,会同步到从库 CREATE TABLE `user` ( `id` ) N ...

  5. python 常见错误和异常 函数 正则表达式及多线程编程

    生成随机密码#!/usr/bin/env python import stringfrom random import choice def gen_pass(num=9): all_chs = st ...

  6. 【其他】Objective-C 内存管理学习总结

    转载请注明出处:http://www.cnblogs.com/shamoyuu/p/OC_CG.html 最近学习了Objective-C语言(以下简称OC),其他的都还好,唯有它的内存管理让我不知所 ...

  7. 【django之form和认证系统小练习】

    作业要求: 作业 : 基于form表单和form组件作业注册页面 基于认证系统实现登录,注册,注销,修改密码 """ Django settings for day20_ ...

  8. Object Detection︱RCNN、faster-RCNN框架的浅读与延伸内容笔记

    一.RCNN,fast-RCNN.faster-RCNN进化史 本节由CDA深度学习课堂,唐宇迪老师教课,非常感谢唐老师课程中的论文解读,很有帮助. . 1.Selective search 如何寻找 ...

  9. jvm类加载器和双亲委派模型

    类加载器按照层次,从顶层到底层,分为以下三种:  (1)启动类加载器(Bootstrap ClassLoader)   这个类加载器负责将存放在JAVA_HOME/lib下的,或者被-Xbootcla ...

  10. error: No curses/termcap library found的解决办法

    mysql版本:5.1.30 已经不记得这次是第几次安装mysql了,遇到这个问题倒是第一次. 之前在tar,./configure,make,make install 经典四步时,从来没有想过其中的 ...