做题思路必须很清晰啊....可以用数组存储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. Nginx下编译PHP+Mysql

    先说一下PHP在Apache和Nginx下所扮演的角色 apache一般是把php当做自己的一个模块来启动的. 而nginx则是把http请求变量(如get,user_agent等)转发给 php进程 ...

  2. 老男孩Python全栈开发(92天全)视频教程 自学笔记16

    day16课程内容: 装饰器: def outer(): x=10 def inner(): print(x) return innerouter()() #inner 是局部变量,10闭包:如果在一 ...

  3. 理解Activity.runOnUiThread()

    这是一篇译文(中英对照),原文链接:Understanding Activity.runOnUiThread() When developing Android applications we alw ...

  4. nyoj281 整数中的1(二) 数位DP

    和整数中的1一毛一样.就是输入时改了一下罢了. AC代码: #include<cstdio> const int maxn = 35; int w[maxn], h[maxn]; void ...

  5. JavaScript基础教程2-20160612

    1.JavaScript之操作html元素,Dom Dom是抽象出来的网页对象,需要了解面向对象的思想:调用对象下的方法实现相应的功能 使用JS调用dom来创建标签. //document是网页对象 ...

  6. FusionCharts封装-单系列图组合

    ChartAction.java: /** * @Title:ChartAction.java * @Package:com.fusionchart.action * @Description:单系列 ...

  7. dojo之FilteringSelect

    1.保证可视框宽度与下拉框宽度一致 forceWidth:'true' 2.控制下拉框的高度 maxHeight:'120'

  8. 错误代码: 1242 Subquery returns more than 1 row

    1. 错误描述 1 queries executed, 0 success, 1 errors, 0 warnings 查询:SELECT t.id, DATE_FORMAT( t.statisTim ...

  9. (二十五)svn的问题

    今天更新代码到svn中的时候出现了错误,准确的说是在操作更新之前的步骤出现了错误,因此对svn有了更近一步的理解.    check:下载svn中的代码到指定的储存路径中:    update:更新s ...

  10. JSP中的include有哪些?有什么区别?

    JSP中的include有哪些?有什么区别? 1.JSP中的include有哪些 (1)<%@include file="" %> (2)<jsp:include ...