转载自:https://blog.csdn.net/fanesemyk/article/details/73441347
求并集:
#include<bits/stdc++.h>
using namespace std;
set<int> s1{1,2,3,5};
set<int> s2{5,7,9};
int main(void)
{
vector<int> ANS;
set_union(s1.begin(),s1.end(),s2.begin(),s2.end(),inserter(ANS,ANS.begin()));
for(auto it:ANS)
cout<<it<<endl;
return 0;
}
求交集:
set_intersection()