jz009

#####青蛙一次可以跳1,2,3***,n个台阶,问有多少种跳法
public static int test1(int n){
int res=0;
if (n<=3){
for (int i=0;i<=n;i++){
res+=i;
}
return res;
}
res=6;
int i=3;
int start =2;
int end =3;
int zc;
while (i<n){
zc=start+end;
res+=zc;
start=end;
end=zc;
i++;
}
return res;
}
posted @ 2021-05-24 10:02  菜鸟哟  阅读(59)  评论(0)    收藏  举报