python练习:冒泡排序
lst=[9,6,5,4,3,2,1,7,8]for i in range(len(lst)):for j in range(len(lst)-i-1):if lst[j]>lst[j+1]:lst[j+1],lst[j]=lst[j],lst[j+1]print(lst)
·
lst=[9,6,5,4,3,2,1,7,8]
for i in range(len(lst)):
for j in range(len(lst)-i-1):
if lst[j]>lst[j+1]:
lst[j+1],lst[j]=lst[j],lst[j+1]
print(lst)
更多推荐
所有评论(0)