题解 | #跳台阶#
跳台阶
http://www.nowcoder.com/practice/8c82a5b80378478f9484d87d1c5f12a4
*
* @param number int整型
* @return int整型
*
* C语言声明定义全局变量请加上static,防止重复定义
*/
int jumpFloor(int number ) {
int tmp_1;
int tmp_2;
int tmp_N;
int i;
if (number <= 2)
return number;
tmp_1 = 1;
tmp_2 = 2;
for (i = 3; i <= number; i++)
{
tmp_N = tmp_1 + tmp_2;
tmp_1 = tmp_2;
tmp_2 = tmp_N;
}
return tmp_N;
}