标签:sum 楼梯 i++ print tair param air class ++
public class Solution {
/**
* @param n: An integer
* @return: An integer
*/
public int climbStairs(int n) {
// write your code here
int a=0,b=1,sum=0;
for(int i=0;i<=n;i++){
if(i==0){
sum=1;
}
else{
sum=a+b;
a=b;
b=sum;
}
}
System.out.println(sum);
return 0;
}
}
标签:sum 楼梯 i++ print tair param air class ++
原文地址:http://www.cnblogs.com/jianjiandan/p/6523248.html