明明的随机数(C++)

明明的随机数

http://www.nowcoder.com/questionTerminal/3245215fffb84b7b81285493eae92ff0

思路:

排序、去重,很容易联想到容器set的性质。

代码:

#include <iostream>
#include <set>

int main()
{
    int n;
    while (std::cin >> n)
    {
        std::set<int> stat;
        int tmp;
        for (int i = 0; i < n; ++i)
        {
            std::cin >> tmp;
            stat.insert(tmp);
        }
        for (auto ele : stat)
        {
            std::cout << ele << std::endl;
        }
    }

    return 0;
}
全部评论

相关推荐

不愿透露姓名的神秘牛友
07-03 17:30
点赞 评论 收藏
分享
头顶尖尖的程序员:我是26届的不太懂,25届不应该是找的正式工作吗?为什么还在找实习?大四还实习的话是为了能转正的的岗位吗
点赞 评论 收藏
分享
评论
1
2
分享

创作者周榜

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