冒泡排序-python

source program:

list=[]
while True:
print("how many number input:")
try:
num=int(input())
for i in range(num):
a=int(input("input"+str((i+1))+"integer:"))
list.append(a)
except ValueError:
print("error!")

for j in range(len(list)-1):
for k in range(len(list)-1):
if list[k]<list[k+1]:
t=list[k]
list[k]=list[k+1]
list[k+1]=t
print(list)



posted @ 2021-04-10 12:13  bobo哥  阅读(54)  评论(0编辑  收藏  举报