arr = [94, 4, 9, 7, 190, 2, 10, 1, 100] def find_second_num(array):
# 索引为0,1的数作为基准,max(最大值),sec(第二大值) max = arr[0] sec = arr[1]
# 循环数组中的索引,从2开始 for i in range(2, len(arr)): if arr[i] > max: sec = max max = arr[i] elif arr[i] > sec: sec = arr[i] else: continue print("第二大的数为:", sec) find_second_num(arr)