#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <iterator>
using
namespace
std;
int
main()
{
const
int
N = 3;
string s1[N] = {
"xp"
,
"python"
,
"linux"
};
string s2[N] = {
"python"
,
"php"
,
"perl"
};
set<string> sa(s1, s1 + N);
set<string> sb(s2, s2 + N);
set<string> sc;
ostream_iterator<string,
char
> out (cout,
" "
);
copy(sa.begin(), sa.end(), out);
cout <<
"->set sa"
<< endl;
copy(sb.begin(), sb.end(), out);
cout <<
"->set sb"
<< endl;
set_union(sa.begin(), sa.end(), sb.begin(), sb.end(), out);
cout <<
"->set_union() 并集"
<< endl;
set_intersection(sa.begin(), sa.end(), sb.begin(), sb.end(), out);
cout <<
"->set_intersection() 交集"
<< endl;
set_difference(sa.begin(), sa.end(), sb.begin(), sb.end(), out);
cout <<
"->set_difference() 集合的差"
<< endl;
set_difference(sb.begin(), sb.end(), sa.begin(), sa.end(), out);
cout <<
"->set_difference() 集合的差"
<< endl;
set_union(sa.begin(), sa.end(), sb.begin(), sb.end(), insert_iterator<set<string> >(sc, sc.begin() ));
sc.insert(
"delphi"
);
copy(sc.begin(), sc.end(), out);
cout <<
"->set sc"
<< endl;
copy(sc.lower_bound(
"perl"
), sc.upper_bound(
"python"
), out);
cout <<
"->显示集合区间"
<< endl;
return
0;
}