码迷,mamicode.com
首页 > 其他好文 > 详细

爬楼梯

时间:2017-07-22 18:20:32      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:ret   solution   strong   public   images   integer   one   int   image   

代码(C++)

class Solution {
public:
/**
* @param n: An integer
* @return: An integer
*/
int climbStairs(int n) {
// write your code here
// write your code here
int one = 0;
int two = 1;
while(n>0) {
two=one+two;
one=two-one;
n--;
}
return two;


}
};

技术分享

爬楼梯

标签:ret   solution   strong   public   images   integer   one   int   image   

原文地址:http://www.cnblogs.com/majixian/p/7221839.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!