牛客网-《剑指offer》-跳台阶

题目:http://www.nowcoder.com/practice/8c82a5b80378478f9484d87d1c5f12a4

C++

1 class Solution {
2 public:
3     int jumpFloor(int n) {
4         if (n == 1 || n == 2) return n;
5         return jumpFloor(n - 1) + jumpFloor(n - 2);
6     }
7 };

 

posted @ 2016-01-08 13:17  ZH奶酪  阅读(205)  评论(0编辑  收藏  举报