c++ stl 已排序区间算法 两个已排序集合的差集set_difference、set_symmetric_difference使用方法
程序员文章站
2022-04-24 22:17:44
...
template<typename T>
inline void PRINT_ELEMENTS(const T & coll, const string& optcstr = "")
{
cout << optcstr;
for (auto elem : coll)
{
cout << elem << ' ';
}
cout << endl;
}
int main()
{
vector<int>a{ 1,2,2,4,6,7,7,9 };
deque<int>b{ 2,2,2,3,6,6,8,9 };
PRINT_ELEMENTS(a, "a: ");
PRINT_ELEMENTS(b, "b: ");
cout << "set_difference: ";
set_difference(a.cbegin(), a.cend(), b.cbegin(), b.cend(), ostream_iterator<int>(cout, " "));
cout << endl;
cout << "set_symmetric_difference: ";
set_symmetric_difference(a.cbegin(), a.cend(), b.cbegin(), b.cend(), ostream_iterator<int>(cout, " "));
cout << endl;
}
上一篇: 整个div居中,不是div中的内容居中
下一篇: 水平居中和垂直居中