赞
踩
def mergeMax(arr): length = len(arr) if length == 1: return arr[0]; max1 = mergeMax(arr[0 : length // 2]) max2 = mergeMax(arr[length // 2 : length]) if max1 > max2: return max1 else: return max2 def mergeMin(arr): length = len(arr) if length == 1: return arr[0] min1 = mergeMin(arr[0 : length // 2]) min2 = mergeMin(arr[length // 2 : length]) if min1 < min2: return min1 else: return min2 arr = [4, 5, 1, 8, 5, 9, 10, 2, 0] # maxNum = mergeMax(arr) # print(maxNum) minNum = mergeMin(arr) print(minNum)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。