//找出列表中最大的数字
def max(list):
if len(list) == 2:
if list[0]>list[1]:
return list[0]
else:
return list[1]
sub_max = max(list[1:])
if list[0] > sub_max:
return list[0]
else:
return sub_max
max([1,2,5,3,0])
#输出
5
编写程序使用递归方法实现找出列表中最大的数字
最新推荐文章于 2023-10-09 19:32:05 发布