[Description] There is a number in each stages that indicates the most stages you can leap up. Now, giving an array which represents one kind of stair, please return if you can leap to the last stage, true if ok and vice versa.

e.g. stair[] = {4,3,1,0,2,1,0}  return true;

  stair[] = {2,1,0,4,3,1,0}  return false;

[Thought] think about: what condition it would be true and false in current stair[0]? how to recursively call itself?

[Implementation] C code:

 #include<stdio.h>

 int leapStage(int stair[], int size)
{
int i;
// if current stage number is zero, false, of course!
if(stair[] == )
{
return ;
}
// if current stage number indicate that we can jump over last stage, true.
else if(stair[] >= size-)
{
return ;
}
// try each way while can't touch the last stages.
for(i = stair[]; i>; i--)
{
// if there is one way can do it, true.
if(leapStage(stair+i, size-i))
{
return ;
}
}
// after try all the way, can't get it.
return ;
} int main()
{
int i;
int stair[]={,,,,,,};
int size=sizeof(stair)/sizeof(stair[]);
for(i=; i<size; i++)
{
printf("%d, ",stair[i]);
}
if(leapStage(stair,size))
{
printf(" is true!\n");
}
else
{
printf(" is false!\n");
}
}

[001] leap_stage的更多相关文章

  1. swift 001

    swift 001  = 赋值是没有返回值的 所以 int a=10; int b=20; if(a=b){ printf("这个是错误的"); } swift  中的模运算 是支 ...

  2. [SDK2.2]Windows Azure Virtual Network (4) 创建Web Server 001并添加至Virtual Network

    <Windows Azure Platform 系列文章目录> 在上一章内容中,笔者已经介绍了以下两个内容: 1.创建Virtual Network,并且设置了IP range 2.创建A ...

  3. 《zw版·Halcon-delphi系列原创教程》 Halcon分类函数001·3D函数

    <zw版·Halcon-delphi系列原创教程> Halcon分类函数001·3D函数 为方便阅读,在不影响说明的前提下,笔者对函数进行了简化: :: 用符号“**”,替换:“proce ...

  4. Android 开发错误信息001

    Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessExceptio ...

  5. python解无忧公主的数学时间编程题001.py

    python解无忧公主的数学时间编程题001.py """ python解无忧公主的数学时间编程题001.py http://mp.weixin.qq.com/s?__b ...

  6. php大力力 [005节] php大力力简单计算器001

    2015-08-22 php大力力005. php大力力简单计算器001: 上网看视频,看了半天,敲击代码,如下: <html> <head> <title>简单计 ...

  7. php大力力 [001节]2015-08-21.php在百度文库的几个基础教程新手上路日记 大力力php 大力同学 2015-08-21 15:28

    php大力力 [001节]2015-08-21.php在百度文库的几个基础教程新手上路日记 大力力php 大力同学 2015-08-21 15:28 话说,嗯嗯,就是我自己说,做事认真要用表格,学习技 ...

  8. Web前端学习笔记(001)

    ....编号    ........类别    ............条目  ................明细....................时间 一.Web前端学习笔记         ...

  9. 001 The Hello World In Csharp

    C#是面向对象编程语言,语法和JAVA非常相似.接下来让我们看一下C#的Hello world. //001.cs using System; public class Hello { public ...

随机推荐

  1. appium1.6.3/1.6.4/1.6.5版本下如何支持安卓下ByName定位

    1. 换其他定位方式,比如用xpath代替 2. 使用ByAccessibilityId代替,感觉没什么效果 一招修改源码解决问题根源,修改方法如下: 找到你的appium\node_modules\ ...

  2. 网页显示百度地图 Jquery

    cshtml: <div class="modal" style="visibility: hidden"> <div id="ma ...

  3. Vue父组件与子组件传递事件/调用事件

    1.Vue父组件向子组件传递事件/调用事件 <div id="app"> <hello list="list" ref="child ...

  4. Shortest Prefixes POJ - 2001(统计次数)

    题意: 输出每个单词的缩写  使得每个单词 互不相同.. 解析: 统计每个前出现的次数...然后在查询的时候  遇到次数为1的返回即可.. #include <iostream> #inc ...

  5. 【转】Oracle 查询库中所有表名、字段名、表名说明、字段名说明

    转自 :http://gis-conquer.blog.sohu.com/170243422.html 查询所有表名:select t.table_name from user_tables t; 查 ...

  6. 【纪念】NOIP2018前夕——一些想说的话

    刚刚复习了一下相关的内容,决定一会儿就洗洗睡了.在睡觉之前,决定写点东西. 有的时候真的很迷茫,选择了一条超过自己能力范围的路,每天挣扎在各种各样难题的面前,文化成绩一落千丈……在从前觉得这一切都是有 ...

  7. HTML option 标签的 selected 属性

    HTML option 标签的 selected 属性 http://www.w3school.com.cn/tags/att_option_selected.asp 1.一般做WEB的时候,Chro ...

  8. 【BZOJ1443】游戏(二分图匹配,博弈论)

    [BZOJ1443]游戏(二分图匹配,博弈论) 题面 BZOJ 题解 很明显的二分图博弈问题. 发现每次移动一定是从一个黑点到达一个白点,或者反过来. 所以可以对于棋盘进行染色然后连边. 考虑一下必胜 ...

  9. Codeforces Round #441 Div. 2题解

    比赛的时候E调了好久...F没时间写T T A:直接走到短的路上来回走就好了 #include<iostream> #include<cstring> #include< ...

  10. python基础----数据类型二

    数据类型 计算机顾名思义就是可以做数学计算的机器,因此,计算机程序理所当然地可以处理各种数值.但是,计算机能处理的远不止数值,还可以处理文本.图形.音频.视频.网页等各种各样的数据,不同的数据,需要定 ...