题解 | #整型数组合并#
整型数组合并
https://www.nowcoder.com/practice/c4f11ea2c886429faf91decfaf6a310b
#include <iostream>
using namespace std;
#include <set>
int main() {
int num1;
cin >> num1;
int temp;
set<int> res;
for (int i = 0; i < num1; i++) {
cin >> temp;
res.insert(temp);
}
cin >> num1;
for (int i = 0; i < num1; i++) {
cin >> temp;
res.insert(temp);
}
for(auto & i : res){
cout << i;
}
}
偷懒的一道题,直接使用set
如果不使用的话用插入法,或者排序后直接去重都行
华为机试刷题记录 文章被收录于专栏
记录一下手打代码的解题思路方便复习
查看1道真题和解析