做题思路必须很清晰啊....可以用数组存储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. yii pageTitle与Yii::app()->name的区别

    我们会在main中修改:  'name'=>'傻逼管理系统', 在视图页中:Yii::app()->name时,会输出  傻逼管理系统:可是当我们用$this->pageTitle时 ...

  2. PHP 支持加解密的函数

    function encrypt($string,$operation,$key=''){ $key=md5($key); $key_length=strlen($key); $string=$ope ...

  3. day5(字符编码、数据类型、列表基本操作)

    一.字符编码 计算器所认识的编码都是二进制编码 二进制与十进制转换 计算机最开始使用的编码是美国的 ASCll编码 计算机容量单位 字符编码 python2.x 默认编码使用的是ASCll pytho ...

  4. span设置宽度有效无效问题

    在html中如何设定span的宽度?这看上去是个很简单的问题,似乎用style中的width属性就可以.例如, <!DOCTYPE html PUBLIC "-//W3C//DTD X ...

  5. Redis实现数据库读写分离

    Redis简介 Redis是一个开源的使用ANSI C语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value数据库,并提供多种语言的API.从2010年3月15日起,Redis的开发工作 ...

  6. Windows平台监听服务无法启动报报TNS-12560 TNS-00530案例

      在Windows Server 2012平台使用命令启动监听服务时遇到了TNS-12560 & TNS-00530错误. C:\Users>lsnrctl start GEW_LIS ...

  7. 动手制作属于你自己的WIN PE3.0

    最近想要更新公司的网Ghost系统,所以小研究一下win pe ,在网上看见一个很不错的教程,在这里分享给大家! 并非原创,纯属转载!!O(∩_∩)O~天缘的作品,很是佩服这个哥们啊..... 一.W ...

  8. 检测dll是32/64位 ?

    检测dll是32/64位 ? void CCheck32Or64Dlg::OnButton2() { CString fileName = ""; CFileDialog *fil ...

  9. 利用Tomcat部署Web项目报错

    1.错误描述 usage: java org.apache.catalina.startup.Catalina [ -config {pathname} ] [ -nonaming ] { -help ...

  10. JavaScript控制输入框中只能输入中文、数字和英文

    1.问题背景 遇到这样一个问题:有一个输入框,要求只能输入中文.数字和英文(即过滤特殊字符串) 2.JS代码 function  checkUsername() { //正则表达式 var reg = ...