题解 | #明明的随机数#

明明的随机数

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

#include <iostream>
#include <set>
using namespace std;

int main() {
    set<int>s; //使用集合将输入的数去重,并排序
    int N; //随机数的个数
    int n; //随机数
    cin >> N;
    while (N--) {
        cin >> n;
        s.insert(n);  //使用集合去重并排序
    }
    //遍历输出随机数
    for (set<int>::iterator it = s.begin(); it != s.end(); it++) {
        cout << *it << endl;
    }
    return 0;
}

全部评论

相关推荐

LemontreeN:有的兄弟有的我今天一天面了五场,4个二面一个hr面
投递字节跳动等公司9个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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