明明的随机数

107 阅读1分钟

1. 题目

image.png

2.考点

使用n个限制输入,还需要考虑去重,使用集合去重,然后对集合进行排序,再逐行输出 注意: sorted会对排序后的序列返回一个列表。

3. 核心代码

while True:
    try:
        n = input()
        ta = []
        for i in range(int(n)):
            ta.append(int(input()))
        uniq = set(ta)
        for j in sorted(uniq):
            print(j)
    except Exception:
        break