跳台阶的算法-python
1 def JumpStep(n): 2 if n <= 0: 3 return 0 4 if n == 1 or n == 2: 5 return n 6 7 return (JumpStep(n-1) + JumpStep(n - 2)) 8 while 1: 9 steps = int(raw_input()) 10 if steps != 0: 11 print "%d cases when steps are %d" % (JumpStep(steps), steps) 12 else: 13 break