题解 | 明明的随机数

明明的随机数

https://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0?tpId=37&tqId=21226&rp=1&sourceUrl=%2Fexam%2Foj%2Fta%3FtpId%3D37&difficulty=undefined&judgeStatus=undefined&tags=&title=

#include <iostream>
#include <set>

using namespace std;

int main() {
    int n;
    cin >> n;
    set<int> unique_numbers;  //直接用set这个数据结构做去重,并且set会自动排序
    
    for (int i = 0; i < n; ++i) {
        int num ;
        cin >> num;
        unique_numbers.insert(num);
    }
    
    for (auto num : unique_numbers) {
        cout << num << endl;
    }
    
    return 0;
}

全部评论

相关推荐

点赞 评论 收藏
分享
Hyh_111:像这种hr就不用管了,基本没啥实力,换一个吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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