题解 | #整型数组合并#

整型数组合并

http://www.nowcoder.com/practice/c4f11ea2c886429faf91decfaf6a310b

使用STL set,set会自动去重和排序。

#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    while(cin >> n){
        set<int> set;
        for(int i = 0; i < n; i++){
            int temp;
            cin >> temp;
            set.insert(temp);
        }
        int m;
        cin >> m;
        for(int i = 0; i < m; i++){
            int temp;
            cin >> temp;
            set.insert(temp);
        }
        for(auto i : set){
            cout << i;
        }
    }
    cout << endl;
    return 0;
}
全部评论
整型数组合并,学到了
点赞 回复 分享
发布于 2022-10-24 11:52 陕西

相关推荐

09-12 18:28
门头沟学院 Java
网友描述的太精准了👍
迷茫的大四🐶:不管活脏还是累,钱到位就行,钱到位啥都不用抱怨
投递字节跳动等公司10个岗位
点赞 评论 收藏
分享
点赞 评论 收藏
分享
熊大不大:恭喜恭喜,我也注册美团众包成功了
投递美团等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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