#include <iostream>
#include <set>
void print(std::string str, std::set<int> set){
std::cout << str << ": ";
for(const int& n: set){
std::cout
<< n
<< " ";
}
std::cout << std::endl;
}
int main(){
std::set<int> x = {3, 12, 5, 6};
std::set<int> y = {6, 10, 5, 1, 7};
print("x集", x);
print("y集", y);
std::set<int> a;
std::set<int> b;
std::set<int> c1;
std::set<int> c2;
std::set<int> d;
std::set_intersection(x.begin(), x.end(), y.begin(), y.end(), inserter(a, a.begin())); // 交集
std::set_union(x.begin(), x.end(), y.begin(), y.end(), inserter(b, b.begin())); // 合集
std::set_difference(x.begin(), x.end(), y.begin(), y.end(), inserter(c1, c1.begin())); // 差
std::set_difference(y.begin(), y.end(), x.begin(), x.end(), inserter(c2, c2.begin())); // 差
std::set_symmetric_difference(x.begin(), x.end(), y.begin(), y.end(), inserter(d, d.begin())); // 对称差
print("x和y的交集", a);
print("x和y的合集", b);
print("x差y的集", c1);
print("y差x的集", c2);
print("x和y的对称差集", d);
return 0;
}