标签:ret int for 排序 pre 列表 次数 冒泡排序 冒泡
def maopao(nums):
for i in range(len(nums)-1): #设置冒泡排序进行的次数
for j in range(len(nums)-i-1): #j 列表的下表
if nums[j] > nums[j+1]:
nums[j], nums[j+1] = nums[j+1], nums[j]
return nums
nums = [1, 2, 7, 3, 9, 8, 5]
print(maopao(nums))
标签:ret int for 排序 pre 列表 次数 冒泡排序 冒泡
原文地址:https://www.cnblogs.com/dlmltao/p/9998685.html