题解 | #明明的随机数#

明明的随机数

https://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0

n = int(input())  # 输入随机整数的个数
nums = set()  # 用集合去重

for i in range(n):
    val = int(input())  # 输入一个随机整数
    nums.add(val)  # 添加到集合中去重

nums = sorted(nums)  # 转换成列表并排序

for num in nums:
    print(num)  # 按照排好的顺序输出

python3

用集合set()先实现去重,再排序

#华为机试HJ3##求职#
全部评论

相关推荐

优秀的大熊猫在okr...:多益:此贼,必有同谋,按律,该当连坐!
你不能接受的企业文化有哪...
点赞 评论 收藏
分享
2025-12-11 14:24
门头沟学院 Java
牛客35720396...:不要用boss,全是骗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务