递归 判断数组最大数字

Posted j657521265

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了递归 判断数组最大数字相关的知识,希望对你有一定的参考价值。

def Max(list):
    if len(list) == 2:
        if list[0] > list[1]:
            return list[0]
        else:
            return list[1]
    max_number = Max(list[1:])
    if list[0] < max_number:
        list[0] = max_number
    return list[0]

if __name__ == __main__:
    list = [5,6,1,2,11,95,67]
    print (Max(list))

 

以上是关于递归 判断数组最大数字的主要内容,如果未能解决你的问题,请参考以下文章