描述
求A和B的合集 并且 按递增序列输出
代码
#include <iostream>
#include <vector>
#include <map>
using namespace std;
void UniSet(vector<int> A, vector<int> B) {
map<int, int> m;
for (int item:A) {
m[item] = 0;
}
for (int item:B) {
m[item] = 0;
}
map<int, int>::iterator it;
for (it = m.begin(); it != m.end(); ++it) {
cout << it->first << " ";
}
cout << endl;
}
int main() {
vector<int> A = {1, 3, 5, 7, 9};
vector<int> B = {1, 5, 2, 4, 9};
UniSet(A, B);
return 0;
}