快速排序
快速排序:
1.递归:
def q_sort(nums): if not nums: return [] else: div = nums[0] left = q_sort([l for l in nums[1:] if l <= div ]) right = q_sort([r for r in nums[1:] if r > div ]) return left+[div]+right input_01 = input('输入排序数列,以 ,分隔:\n') nums1 = [] nums1 += [int(i) for i in input_01.split(',')] nums1_1 = q_sort(nums1) print (nums1_1)