总是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. 用val()获取与设置input的值

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  2. theano报一种float类型错误的处理办法

    我实际用的环境是Keras,查错误时查到是Theano的配置问题,所以在标题里就写成Theano的问题了, 是这样的,从Github上下载的别人的代码,准备复现别人的实验,结果在机器上部署好环境之后跑 ...

  3. stl(set+stack) LA 3634 The SetStack Computer

    题目传送门 题意:给一些对集合的操作,询问每一次操作后栈顶的集合元素个数 分析:首先{}是空的,每一次add时候,{} -> { {} }变成了有一个元素的集合,利用set和stack,map容 ...

  4. PHP、Java输出json格式数据

      PHP 输出json. $result = mysql_query($sql); //查询结果 $users=array(); $i=0; while($row=mysql_fetch_array ...

  5. wordpress安装步骤

    步骤1.因为安装Wordpress需要用到Apache和Mysql数据库,可以选择单独安装这两个软件,但配置参数设置起来可能会遇到一些困扰,建议大家下载现成的PHP和Mysql的集成安装包,比如XAM ...

  6. 【原】iOS多线程之异步任务+并行队列情况与异步任务+串行队列(主队列)情况

    异步任务+并行队列 把异步任务放到并行队列进行执行,异步任务会在不同的线程中执行. /*异步执行+并行队列*/ - (IBAction)clickBasic1:(UIButton *)sender { ...

  7. Extjs tree的相关方法及配置项

    Ext.tree.TreePanel       主要配置项:             root:树的根节点.             rootVisible:是否显示根节点,默认为true.     ...

  8. ACM 字符串替换

    字符串替换 时间限制:3000 ms  |  内存限制:65535 KB 难度:2   描述 编写一个程序实现将字符串中的所有"you"替换成"we"   输入 ...

  9. thinkphp 联表查询,排序

    $info =M('productbase'); $info= $info->alias('a')->field('a.id,cid,title,address,protype,time, ...

  10. jQuery取得select选中的值

    $("#sxselect").change(function(){ alert($("#sxselect option:selected").val()); } ...