题解 | #整型数组合并#

整型数组合并

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

用标准库stl的set自动排序加去重
#include <algorithm>
#include <set>

using namespace std;

int main() {
    int n1,n2;
    while(cin>>n1){
        set<int> iset;
      for(int i = 0;i<n1;i++){
          int temp;
          cin>>temp;
          iset.insert(temp);
          
      }
        cin>>n2;
        for(int j = 0;j<n2;j++){
            int temp;
            cin>>temp;
            iset.insert(temp);
            
        }
        for(auto it = iset.begin();it!=iset.end();it++){
            cout<<(*it);
            
        }
        
    }
}

全部评论

相关推荐

怎么起名字:早知道就不读书了,害得我送外卖还得扶眼镜
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-10 11:45
你不要过来啊啊啊啊啊啊啊
码农索隆:对面:“今天你不面也得面”
点赞 评论 收藏
分享
醉蟀:你不干有的是人干
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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