def bubblesSort(seq):
for i in range(len(seq)-1,0,-1):
for j in range(0,i):
if seq[j]>seq[j+1]:
seq[j],seq[j+1]=seq[j+1],seq[j]
a=[3,9,1,4,7,6,5,8,2]
bubblesSort(a)
print(a)
python冒泡排序
最新推荐文章于 2024-07-21 22:27:18 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)