题解 | #明明的随机数#

明明的随机数

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

#include <bits/stdc++.h>
#include <cstdio>
using namespace std;

void printSet(set<int>& s) {
    for (set<int>::iterator it = s.begin(); it != s.end(); it++) {
        cout << *it << endl;

    }
}


int main() {
    set<int> s1;
    int a, b;
    cin>>a;
    for (int i = 0; i < a; i++) {
        cin >> b;
        s1.insert(b);
    }
    printSet(s1);

}
// 64 位输出请用 printf("%lld")

set不允许容器中有重复的元素 所有元素都会在插入时自动被排序

全部评论

相关推荐

10-17 23:18
已编辑
西北农林科技大学 Web前端
独行m:给25可以试试,但他只能给12,那就是纯纯的事精
秋招,不懂就问
点赞 评论 收藏
分享
叁六玖:你看,最后不是让你加油,就是鼓励你,还祝福你求职顺利。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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