题解 | #明明的随机数#

明明的随机数

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

去重复+排序,一眼用set。

#include <iostream>
#include <vector>
#include <set>

void DelDupAndSort(std::vector<int>& nums){
    std::set<int> occ(nums.begin(), nums.end());
    for(auto ele : occ){
        std::cout << ele << std::endl;
    }
}

int main(int argc, char* argv[]){
    int N;
    std::cin >> N;
    std::vector<int> nums(N, 0);
    int num;
    int i = 0;
    while(std::cin >> num){
        nums[i++] = num;
    }
    DelDupAndSort(nums);
    return 0;
}
全部评论

相关推荐

03-04 19:02
云南大学 Java
Yki_:没挂,只是没人捞,该干啥干啥,等着就好了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务