nums = [2,5,2,9,0]
x = nums[0]
for num in nums:
if num > x:
x = num
print('最大数是{},对应的下标是{}'.format(x,nums.index(x)))
nums4 = [2,5,2,9,0]
i = 0
x = nums4[0]
index = 0
while i < len(nums4):
if nums4[i] > x:
x = nums4[i]
index = i
i += 1
print('最大数是{},对应的下标是{}'.format(x,index))
nums2 = [2,5,2,9,0]
nums2.sort()
print(nums2[-1])
nums3 = [2,5,2,9,0]
nums3.sort(reverse=True)
print(nums3[0])
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)