总是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. 通过jquery.transit.min.js插件,实现图片的移动

    首先给出插件:jquery.transit.min.js (function(t,e){if(typeof define==="function"&&define. ...

  2. mvc-9测试和调试

    单元测试 单元测试是比集成测试更底层的测试,用于确保特定的后台代码片段能正常运行; 前端单元测试更多是为了发现浏览器兼容性的bug; 断言 断言是测试的核心,是一些表述代码期望执行结果的语句 //正确 ...

  3. sql server 2008 跨服务器查询

    exec sp_addlinkedserver 'ITSV','','SQLOLEDB','192.168.202.53' exec sp_addlinkedsrvlogin 'ITSV','fals ...

  4. Codeforces Round #344 (Div. 2)

    水 A - Interview 注意是或不是异或 #include <bits/stdc++.h> int a[1005], b[1005]; int main() { int n; sc ...

  5. 使用sqoop 在关系型数据库和Hadoop之间实现数据的抽取

    (一)从关系型数据库导入至HDFS 1.将下面的参数保持为 import.script import --connectjdbc:mysql://192.168.1.14:3306/test--use ...

  6. MFC 重载退出(窗口顶上最右边的x按钮)

    其实可以在*Dlg.cpp中的BEGIN_MESSAGE_MAP中对IDCANCEL和自定义函数进行匹配就可以了. 如: 自定义的退出函数是OnClose(),则在BEGIN_MESSAGE_MAP中 ...

  7. CF# 334 Moodular Arithmetic

    B. Moodular Arithmetic time limit per test 1 second memory limit per test 256 megabytes input standa ...

  8. apr 内存管理

    //============================================================================ // Name : mytest.cpp ...

  9. 【BZOJ4260】 Codechef REBXOR 可持久化Trie

    看到异或就去想前缀和(⊙o⊙) 这个就是正反做一遍最大异或和更新答案 最大异或就是很经典的可持久化Trie,从高到低贪心 WA: val&(1<<(base-1))得到的并不直接是 ...

  10. 升级OS X EI Capition 版本导致cocoapods 使用终端上pod: command not found

    1)安装过cocoapods, 那么输入 : sudo gem install -n /usr/local/bin cocoapods 当然 上个步骤解决了我的 难题 2)首先在终端输入 gem so ...