Leetcode 70

class Solution {
public:
    int climbStairs(int n) {
        if(n == 1)return 1;
        if(n == 2)return 2;
        int x = 1;
        int y = 2;
        while(n-2){
            int t = y;
            y = x+y;
            x = t;
            n--;
        }
        return y;
    }

};
原文地址:https://www.cnblogs.com/cunyusup/p/9832542.html