python 小案例demo04
# 4、冒泡排序 以及反转 和 排序方法 升序和降序
a = [-1,12,31,2,134,2345,2]
for i in range(0,len(a)-1,1):
for j in range(0,len(a)-1-i,1):
if a[j] > a[j+1]:
tem = 0
tem = a[j]
a[j] = a[j+1]
a[j+1] = tem
for i in a:
print(i,end="\t")
# 4、冒泡排序 以及反转 和 排序方法 升序和降序
a = [-1,12,31,2,134,2345,2]
for i in range(0,len(a)-1,1):
for j in range(0,len(a)-1-i,1):
if a[j] > a[j+1]:
tem = 0
tem = a[j]
a[j] = a[j+1]
a[j+1] = tem
for i in a:
print(i,end="\t")