我正在尝试打印出一个值表,以告诉科学家科学家可以在兔子用完笼子之前让它们再繁殖多少个月。我不知道在我的for循环中使用什么范围。一旦兔子总数超过输入的笼数,我就需要停止它。这是我的东西:
cages = int(input("How many cages do you have? "))
print("Month\t", "Adults\t", "Babies\t", "Total")
def fib(n):
if n < 2:
return n
return fib(n-2) + fib(n-1)
n = 1
total = fib(n+2)
adults = fib(n+1)
babies = fib(n)
if total < cages:
## dont know what to put in range here to make the loop stop at the
## correct place
for n in range(cages):
print((n+1), "\t", fib(n + 1), "\t", fib(n), "\t", fib(n+2))
print("You ran out of cages!")
“笼子”的范围似乎不合适,因为总数量远大于笼子的数量。
答案 0 :(得分:1)
您需要的是src/runtime/x86-assem.S
。尝试类似
break