总是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. 使用openface(linux)

    在github上搜索openface,clone下来; 按照requirement.txt中安装需要的项: sudo apt-get install .... sudo pip install ... ...

  2. DOM--6 向应用程序中加入ajax

    组合技术 适当的ajax时对已有技术和下列思想的组合 语义化(X)HTML标记 文档对象模型(DOM) JavaScript XML 不同浏览器中,公共XMLHttpRequest方法 open(me ...

  3. 表格边框css

    table标签默认是没有边框的,但是如果我们自己加上边框boder:1px solid black;只有整个表格最外面有边框,那么如何给表格添加样式使得整个表格的tr.td都具有边框呢: <st ...

  4. 图论 SRM 674 Div1 VampireTree 250

    Problem Statement      You are a genealogist specializing in family trees of vampires. Vampire famil ...

  5. Sprint回顾_团队听诊器

  6. unity 解析tmx 2

    using UnityEngine; using System.Collections; using System.Collections.Generic; using System.IO; usin ...

  7. BZOJ3654 : 图样图森破

    考虑枚举回文中心,然后向两边扩展,当匹配到当前串的边界的时候,枚举下一个串接上. 这个过程可以通过记忆化搜索来完成,设: $f[i][0]$表示对于$i$这个位置,$[i,串结尾]$等待匹配的最长回文 ...

  8. ubuntu server下建立分区表/分区/格式化/自动挂载(转)

    link:http://www.thxopen.com/linux/2014/03/30/Linux_parted.html 流程为:新建分区-->格式化分区-->挂载分区 首先弄明白分区 ...

  9. Web标准中用于改善Web应用程序性能的各种方法总结

    提起Web应用程序中的性能改善,广大开发者们可能会想到JavaScript与DOM访问等基于各种既存技术的性能改善方法.最近,各种性能改善方法被汇总成为一个Web标准. 本文对Web标准中所包含的各种 ...

  10. Nginx 利用 X-Accel-Redirect response.setHeader 控制文件下载

    nginx.conf location / { proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP ...