题解 | #明明的随机数#
明明的随机数
https://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0
# 全部接受所有不重复的数据生成列表 # 快速排序 10min搞定 n = int(input()) lst1 = [] while n>0: num_in = int(input()) if num_in not in lst1: lst1.append(num_in) n -= 1 # 快速排序 def partition(data, left, right): tmp = data[left] while left < right: while left < right and data[right] >= tmp: right -=1 data[left] = data[right] while left < right and data[left] <= tmp: left += 1 data[right] = data[left] data[left] = tmp return left def quick_sort(data, left, right): if left < right: mid = partition(data, left, right) quick_sort(data, mid+1, right) quick_sort(data, left, mid-1) quick_sort(lst1, 0, len(lst1)-1) for i in range(len(lst1)): print(lst1[i])