题解 | 明明的随机数

明明的随机数

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

#牛客春招刷题训练营# https://www.nowcoder.com/discuss/727521113110073344

使用set集合去重,同时set默认就是从小到大排序,直接使用auto输出即可

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

int main() {
    int n;
    cin >> n;
    set<int> st;
    for(int i = 0 ; i < n ; i ++) {
        int x;cin>>x;
        st.insert(x);
    }
    for(auto x : st) {
        cout << x <<endl;
    }
}
// 64 位输出请用 printf("%lld")

#牛客春招刷题训练营#
全部评论

相关推荐

03-30 23:51
门头沟学院 C++
点赞 评论 收藏
分享
02-28 01:18
已编辑
南昌大学 后端工程师
黑皮白袜臭脚体育生:把开源经历放个人项目上边应该更好,就像大部分人都把实习经历放个人项目上边
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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