# coding=utf-8
a = [1, 8, 9, 6, 11, 3, 8, 2, 333]
for i in range(len(a)-1):
for j in range(i+1, len(a), 1):
if(a[i] > a[j]):
a[j], a[i] = a[i], a[j]
print(a)
python冒泡排序
最新推荐文章于 2022-08-11 18:02:48 发布
# coding=utf-8
a = [1, 8, 9, 6, 11, 3, 8, 2, 333]
for i in range(len(a)-1):
for j in range(i+1, len(a), 1):
if(a[i] > a[j]):
a[j], a[i] = a[i], a[j]
print(a)