冒泡排序
2020-09-22 本文已影响0人
木子李007
list = [5,3,4,7,2,1,6]
for i in range(len(list)-1):
for j in range(i,len(list)):
if list[j] < list[i]:
list[i],list[j] = list[j],list[i]
print(list)
list = [5,3,4,7,2,1,6]
for i in range(len(list)-1):
for j in range(i,len(list)):
if list[j] < list[i]:
list[i],list[j] = list[j],list[i]
print(list)