题解 | 明明的随机数

明明的随机数

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")

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

相关推荐

2025-12-18 11:59
广州南方学院 C++
牛客78682892...:直接点还好,总比要了简历也不回的强
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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