AcWing 821. 跳台阶

 参考:https://www.acwing.com/solution/acwing/content/2163/

class Solution {
public:
    int jumpFloor(int number) {
        int res;
        if(number ==1 ) res =  1;
        if(number ==2)  res =  2;
        if(number > 2)  res = jumpFloor(number-1) +jumpFloor(number-2);
        return res;
        
    }
};

猜你喜欢

转载自www.cnblogs.com/make-big-money/p/12364908.html