leetcode70 C++ 4ms 爬楼梯 菲波那切数列

class Solution {
public:
    int climbStairs(int n) {
        int a = 1;
        int b = 1;
        int temp;
        while(n>0){
            n--;
            temp = a;
            a = b;
            b += temp;
        }
        return a;
    }
};
posted @ 2018-08-03 11:57  一条图图犬  阅读(227)  评论(0编辑  收藏  举报