数组和集合 / 无重复集合

#include <iostream>
#include <set>
using namespace std;

set<intfirst = { 12 };
set<intsecond = { 21 };
set<int> third = { 123 };

bool isEqual = first == second;
//isEqual is 1

set<int> intersect;
set_intersection(
    first.begin(), first.end(),
    third.begin(), third.end(),
    inserter(intersect, intersect.begin()));
bool isIntersects = intersect.size() > 0;
//isIntersects is 1

bool isSubset = includes(
    first.begin(), first.end(),
    third.begin(), third.end());
//isSubset is 0

cout << "isEqual is " << isEqual << endl;
cout << "isIntersects is " << isIntersects << endl;
cout << "isSubset is " << isSubset;