标签:scribe target int lse for i++ 先后 结果 describe
1 public int JumpFloor(int target) { 2 if(target==1) 3 return 1; 4 else if(target==2) 5 return 2; 6 else 7 return JumpFloor(target-1)+JumpFloor(target-2); 8 }
解法2:循环解法
1 public int JumpFloor(int target) { 2 int a=1,b=2; 3 int c=0; 4 if(target==1) 5 return 1; 6 else if(target==2) 7 return 2; 8 for(int i=3;i<=target;i++) { 9 c=a+b; 10 a=b; 11 b=c; 12 } 13 return c; 14 }
标签:scribe target int lse for i++ 先后 结果 describe
原文地址:https://www.cnblogs.com/jacob-wuhan/p/12955985.html