题解 | 明明的随机数
def generate_unique_sorted_numbers(i): # 输入i个数 s = [] for _ in range(i): while True: try: number = int(input()) if 1<= number <= 500: s.append(number) break else: print("请输入1-500的数字") except ValueError: print("无效输入") s2 = set(s)//去重 sorted_numbers = sorted(s2)//排序 # 返回排序后的列表 return sorted_numbers i = int(input().strip()) resu = generate_unique_sorted_numbers(i) # 输出最终的排序结果 for number in resu: print(number)