python基础之冒泡排序
2020-12-13 14:57
标签:pytho 基础 print 输出 for list 结果 tis i+1 python基础之冒泡排序 标签:pytho 基础 print 输出 for list 结果 tis i+1 原文地址:https://blog.51cto.com/9237101/2440144list_pratisce = [45,69,8,19,9]
n = len(list_pratisce)
for j in range(n):
for i in range(n-1):
if list_pratisce[i] > list_pratisce[i+1]:
temp = list_pratisce[i]
list_pratisce[i] = list_pratisce[i+1]
list_pratisce[i+1] = temp
print(list_pratisce)
输出结果:
[8, 9, 19, 45, 69]
下一篇:风格迁移算法