题解 | #明明的随机数#

明明的随机数

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不允许容器中有重复的元素 所有元素都会在插入时自动被排序

全部评论

相关推荐

09-28 22:01
已编辑
广西科技大学 IT技术支持
合适才能收到offe...:找桌面运维?
点赞 评论 收藏
分享
10-17 13:54
上海大学 运营
雾凇岛:这还说什么了,冲了兄弟们
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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