[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. Kafka生产者各种启动参数说明

    首先是启动一个生产者 final String kafkazk="localhost:9092"; String topic="testAPI"; Proper ...

  2. 洛谷 P2763 试题库问题(网络流24题之一)

    题目描述 «问题描述: 假设一个试题库中有n道试题.每道试题都标明了所属类别.同一道题可能有多个类别属性.现要从题库中抽取m 道题组成试卷.并要求试卷包含指定类型的试题.试设计一个满足要求的组卷算法. ...

  3. WPF 如何加载图片

    Uri ri = new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources/exp.jpg"); ImageSource ...

  4. hdu5279 YJC plays Minecraft 【分治NTT】

    题目链接 hdu5279 题解 给出若干个完全图,然后完全图之间首尾相连并成环,要求删边使得两点之间路径数不超过\(1\),求方案数 容易想到各个完全图是独立的,每个完全图要删成一个森林,其实就是询问 ...

  5. 洛谷P1890 gcd区间

    题目描述 给定一行n个正整数a[1]..a[n]. m次询问,每次询问给定一个区间[L,R],输出a[L]..a[R]的最大公因数. 输入输出格式 输入格式: 第一行两个整数n,m. 第二行n个整数表 ...

  6. valgrind检查C/C++内存泄漏

    valgrind --tool=memcheck --leak-check=full ./httptest  valgrind --tool=memcheck --leak-check=full -- ...

  7. mac和linux下sed使用的不同

    http://note.youdao.com/noteshare?id=84a6a0eb3e3f1698c9de4f48db24226e

  8. tp 中 where条件,字段和字段的大小比较

    $map = array( , 'start_time' => array('lt',$now), 'end_time' => array('gt',$now), , '_string' ...

  9. 类的起源与metaclass

    一.概述 我们知道类可以实例化出对象,那么类本身又是怎么产生的呢?我们就来追溯一下类的起源. 二.类的起源 2.1 创建一个类 class Foo(object): def __init__(self ...

  10. linux 查看登录日志

    原文:http://www.cnblogs.com/wangkangluo1/archive/2011/09/23/2185976.html linux查看日志: # cd /var/log # le ...