myList=[4,1,7,0]
print(len(myList))
for i in range(len(myList)-1):#每循环一次找出最大值
for j in range(0,len(myList)-1-i):
if myList[j]>myList[j+1]:
tmp=myList[j]
myList[j]=myList[j+1]
myList[j+1]=tmp
print(myList)
python学习二十二(冒泡排序)
最新推荐文章于 2024-01-10 00:04:27 发布