递归

2016-10-25  本文已影响0人  Xiasiyu

如果你听说过递归,你会发现用中文或者英文或者数学语言来描述它非常麻烦,下面是一段Python代码:

global expectancy 

def Life():
    Awake()
    Eat()
    try:
        Work()
    except TuoYanZheng:
        Play()
    Others(option)
    Shit()
    Sleep()
    expectancy-= 1
    if expectancy <= 0:
        return "death"
    else:
        return Life()

我相信任何一个高中文化水平的人都能看懂这段代码。
递归是阿里面试的必考题。

上一篇 下一篇

猜你喜欢

热点阅读