做题思路必须很清晰啊....可以用数组存储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. 彻底解决Yii2中网页刷新时验证码不刷新的问题

    修改vendor/yiisoft/yii2/captcha/CaptchaValidator.php这个文件就可以了,修改的地方见下图: 总结 归根到底,是因为yii2在渲染网页的时候,会先输出js验 ...

  2. 《设计模式之禅》--MVC框架

    需求:设计一个MVC框架 (以下可能摘要不全,后期整理) 架构图: * 核心控制器:MVC框架入口,负责接收和反馈HTTP请求 * 过滤器:Servlet容器内的过滤器,实现对数据的过滤处理 * 拦截 ...

  3. React Native填坑之旅 -- 回归小插曲

    回归RN,非常开心啊! 在React Native 0.49.5上开发,直接遇到一个ios模拟器的问题.这个问题很简单就是Bundle URL not present. 在网上找了很多的解决方法,都不 ...

  4. VNCServer,SSH Secure Shell Client,window远程控制linux

    1.VNC远程连接linux图形化桌面 2.SSH Secure Shell Client连接linux终端 3.设置FTP与linux传输文件 1.VNC远程连接linux图形化桌面 在centos ...

  5. Python基础学习参考(六):列表和元组

    一.列表 列表是一个容器,里面可以放置一组数据,并且列表中的每个元素都具有位置索引.列表中的每个元素是可以改变的,对列表操作都会影响原来的列表.列表的定义通过"[ ]"来定义,元素 ...

  6. javascript-深入理解&&和||

    先从两个问题看起: 第一个问题 为什么 a && b 返回的是true,b && a 返回的是6 var user = 6; var both = true; cons ...

  7. SAS︱操作语句(if、do、select、retain、array)、宏语言、统计量、运算符号

    每每以为攀得众山小,可.每每又切实来到起点,大牛们,缓缓脚步来俺笔记葩分享一下吧,please~ --------------------------- SAS中的一些常见的符号.运算符是一种符号①比 ...

  8. Android常见Crash类型分析(一)

    问题1.   java.lang.IllegalStateException: The specified child already has a parent. You must call remo ...

  9. 芝麻HTTP:在无GUI的CentOS上使用Selenium+Chrome

    各位小伙伴儿的采集日常是不是被JavaScript的各种点击事件折腾的欲仙欲死啊?好不容易找到个Selenium+Chrome可以解决问题! 但是另一个▄█▀█●的事实摆在面前,服务器都特么没有GUI ...

  10. 教我徒弟Android开发入门(三)

    前言: 老实说,我有点不知道该讲什么了,希望看过的人能给我提提意见,感激不尽. 本期知识点: 长按事件,log的简单使用,双击退出程序功能的实现 正文: 上一期我们了解到点击事件其实就是让控件绑定一个 ...