软件工程test1-Q3【爬楼梯】

class Solution {
public:
/**
* @param n: An integer
* @return: An integer
*/
int climbStairs(int n) {
// write your code here
int a,b;
a=b=1;
int c;
if(n==1||n==0)
return 1;
else
while(--n>0)
{
c=a+b;
a=b;
b=c;
}
return c;
}
};

原文地址:https://www.cnblogs.com/wangym-crystal/p/6506863.html