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)
本文标题:冒泡排序
本文链接:https://www.haomeiwen.com/subject/cviwyktx.html
网友评论