总是wa~

#include <stdio.h>
int main()
{
int n, i, j, k, atop, cmd[];
char a[], b[];
while(scanf("%d %s %s", &n, a, b) != EOF){ for(i = , j = , k = ; i < n; i++){ atop = i + ;
cmd[k++] = ;
while(atop > && a[atop - ] == b[j]){ cmd[k++] = ;
j++;
atop--; } }
if(j == n)
{ printf("Yes.\n");
for(i = ; i < k; i++){ if(cmd[i] == )
printf("in\n");
else
printf("out\n"); }
printf("FINISH\n"); }
else
{ printf("No.\nFINISH\n"); } }
return ;
}

经过修改,发现问题出现在栈的使用,调试了这组数据:5 67543 74536,才发现自己没有清栈。

 #include <stdio.h>
int main()
{
int n, i, j, k, top, cmd[];
char a[], b[], c[];
while(scanf("%d %s %s", &n, a, b) != EOF){ top = ;
for(i = , j = , k = ; i < n; i++){ c[top++] = a[i];/*入栈*/
cmd[k++] = ;
while(c[top-] == b[j]){ c[top-] = ;/*出栈*/
top--;
cmd[k++] = ;
j++; } }
if(j == n)
{ printf("Yes.\n");
for(i = ; i < k; i++){ if(cmd[i] == )
printf("in\n");
else
printf("out\n"); }
printf("FINISH\n"); }
else
{ printf("No.\nFINISH\n"); } }
return ;
}

解决此问题后,写下自己的用栈心得:

入栈,先赋值再上移栈顶;

出栈,清零再下移栈顶。

注意:一定要保持栈的数目不变,这样才是栈的使用规则

Rails problem的更多相关文章

  1. rails work

    4.2 Say "Hello", Rails problem weppack not install solve run the command rails webpacker:i ...

  2. OpenJudg / Poj 1363 Rails

    1.链接: http://poj.org/problem?id=1363 http://bailian.openjudge.cn/practice/1363 2.题目: Rails Time Limi ...

  3. usaco training 4.1.2 Fence Rails 题解

    Fence Rails题解 Burch, Kolstad, and Schrijvers Farmer John is trying to erect a fence around part of h ...

  4. Choosing web framework: ASP.NET MVC vs Django Python vs Ruby on Rails(转载)

    来源:http://podlipensky.com/2012/06/choosing-web-framework-asp-net-mvc-vs-django-python-vs-ruby-on-rai ...

  5. 算法之路 level 01 problem set

    2992.357000 1000 A+B Problem1214.840000 1002 487-32791070.603000 1004 Financial Management880.192000 ...

  6. USACO 6.3 Fence Rails(一道纯剪枝应用)

    Fence RailsBurch, Kolstad, and Schrijvers Farmer John is trying to erect a fence around part of his ...

  7. Rails NameError uninitialized constant class solution

    rails nameerror uninitialized constant class will occur if your rails console is not loaded with con ...

  8. UVA 514 - Rails ( 铁轨)

    from my CSDN: https://blog.csdn.net/su_cicada/article/details/86939523 例题6-2 铁轨(Rails, ACM/ICPC CERC ...

  9. USACO 4.1 Fence Rails

    Fence RailsBurch, Kolstad, and Schrijvers Farmer John is trying to erect a fence around part of his ...

随机推荐

  1. JAVA第三周作业

    一:枚举 package homework; public class EnumTest { public static void main(String[] args) { Size s=Size. ...

  2. mac OS X操作 -- 常用

    显示/隐藏默认隐藏文件:defaults write com.apple.finder AppleShowAllFiles -bool true/false 重置ROOT密码: http://www. ...

  3. 快销品 车销批发管理手持终端PDA系统 打印开单 入库 库存 盘点多功能一体

    手持POS终端PDA移动开单 PDA通过扫描商品条码移动开单,实现便携式办公,伴随式销售,浩瀚技术研发团队开发的一款最新产品,PDA能通过WIFI无线局域网.GPRS互联网直接与主机连接,让公司业务人 ...

  4. BZOJ 2648 SJY摆棋子 ——KD-Tree

    [题目分析] KD-Tree第一题,其实大概就是搜索剪枝的思想,在随机数据下可以表现的非常好NlogN,但是特殊数据下会达到N^2. 精髓就在于估价函数get以及按照不同维度顺序划分的思想. [代码] ...

  5. js与jquery异同

    大家都知道jquery是js的一个库,很多东西大多数简写了,让js写起来特别的方便.但是对与学习的人来说,最好是先学会了js再去学jquery会更好.在学得过程中你会发现两者实现的原理是差不多的,但是 ...

  6. DFS(连通块) ZOJ 2743 Bubble Shooter

    题目传送门 题意:从炮台射出一个球,三个及以上颜色相同的会掉落,问最后会掉落多少个球 分析:先从炮台找一个连通块,然后与顶部连接的连通块都不会掉落,剩下的就是炮台射出后跟随掉落的. #include ...

  7. AC自动机 LA 4670 Dominating Patterns

    题目传送门 题意:训练指南P216 分析:求出现最多次数的字串,那么对每个字串映射id,cnt记录次数求最大就可以了. #include <bits/stdc++.h> using nam ...

  8. Bower In ASP.NET Core

    创建一个ASP.NET Core MVC项目的时候,会产生一个bower.json的文件,用于管理前段的js. NPM & Bower NPM主要运用于Node.js项目的内部依赖包管理,安装 ...

  9. Redis List命令

        命令 解释 lpush key string 在key对应list的头部添加字符串元素,返回1表示成功,0表示key存在且不是list类型. rpush key string 同上,尾插入. ...

  10. MongoDB 入门之基础 DML

    此文章主要记录部分主要的 MongoDB Collection 的 DML 操作. 文章中的 Collection 名字为 yourColl,每一次操作包含以下两条初始数据 { "_id&q ...