青蛙跳台阶(递归算法)

题目:青蛙跳台阶算法,每次可以跳1级或两级,请问有n级台阶,有多少种算法

package bianchengti;
/*
 * 青蛙跳台阶算法
 * 每次可以跳1级或两级,请问有n级台阶,有多少种算法
 * 递归算法
 */
public class FrogJump {
    public static int JumpFloor(int n) {
        if(n<0)
            return 0;
        int []fibArry = {0,1,2};
        if(n<3)
            return fibArry[n];
        return JumpFloor(n-1)+JumpFloor(n-2);
    }
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.out.println(JumpFloor(5));//8
    }

}
原文地址:https://www.cnblogs.com/liuzhenping/p/7580903.html