python冒泡排序

python冒泡排序

array=[8,4,87,20,33,10,43]

count=len(array)
for i in range(count):
for j in range(i):
if array[j]>array[j+1]:
array[i],array[j]=array[j],array[i]
print array

打印结果:
[4, 8, 20, 43, 10, 33, 87]

posted @ 2022-09-05 10:06  赏金猎人小熊  阅读(14)  评论(0编辑  收藏  举报