0
点赞
收藏
分享

微信扫一扫

冒泡排序-python

Python芸芸 2022-06-08 阅读 91

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)


举报

相关推荐

0 条评论