multiset的使用
来源:互联网 发布:mysql 允许本地登录 编辑:程序博客网 时间:2024/05/29 19:35
#include <set>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{ const int N = 10;
int a[N] = {4, 1, 1, 1, 1, 1, 0, 5, 1, 0};
int b[N] = {4, 4, 2, 4, 2, 4, 0, 1, 5, 5};
multiset<int> A(a, a + N);
multiset<int> B(b, b + N);
multiset<int> C;
cout << "Set A: ";
copy(A.begin(), A.end(), ostream_iterator<int>(cout, " "));
cout << endl;
cout << "Set B: ";
copy(B.begin(), B.end(), ostream_iterator<int>(cout, " "));
cout << endl;
cout << "Union: ";
set_union(A.begin(), A.end(), B.begin(), B.end(),ostream_iterator<int>(cout, " "));
cout << endl;
cout << "Intersection: ";
set_intersection(A.begin(), A.end(), B.begin(), B.end(),ostream_iterator<int>(cout, " "));
cout << endl;
set_difference(A.begin(), A.end(), B.begin(), B.end(),inserter(C, C.begin()));
cout << "Set C (difference of A and B): ";
copy(C.begin(), C.end(), ostream_iterator<int>(cout, " "));
cout << endl;
}
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{ const int N = 10;
int a[N] = {4, 1, 1, 1, 1, 1, 0, 5, 1, 0};
int b[N] = {4, 4, 2, 4, 2, 4, 0, 1, 5, 5};
multiset<int> A(a, a + N);
multiset<int> B(b, b + N);
multiset<int> C;
cout << "Set A: ";
copy(A.begin(), A.end(), ostream_iterator<int>(cout, " "));
cout << endl;
cout << "Set B: ";
copy(B.begin(), B.end(), ostream_iterator<int>(cout, " "));
cout << endl;
cout << "Union: ";
set_union(A.begin(), A.end(), B.begin(), B.end(),ostream_iterator<int>(cout, " "));
cout << endl;
cout << "Intersection: ";
set_intersection(A.begin(), A.end(), B.begin(), B.end(),ostream_iterator<int>(cout, " "));
cout << endl;
set_difference(A.begin(), A.end(), B.begin(), B.end(),inserter(C, C.begin()));
cout << "Set C (difference of A and B): ";
copy(C.begin(), C.end(), ostream_iterator<int>(cout, " "));
cout << endl;
}
- multiset的使用
- multiset的使用
- std::multiset 的使用
- multiset(STL)的使用
- CF603E,multiset的使用要点
- multiset的使用以及集合的运算
- STL set和multiset的使用
- c++ STL set和multiset的使用
- C++ STL set和multiset的使用
- C++ STL set和multiset的使用
- c++ STL set和multiset的使用
- multiset容器使用上的一些疑问
- C++ STL set和multiset的使用
- C++ STL set和multiset的使用
- guava multimap 和 multiset的使用
- C++ STL set和multiset的使用
- multiset find使用...
- Set与MultiSet使用
- deque的用法
- find的使用
- multimap的使用
- map与pair的使用
- map的使用
- multiset的使用
- set的使用
- 听听售楼的另一面的解说
- class()的妙用
- VC版本的声明
- 智能语义参透股票 小公司不见得比输大公司
- window.onload 关于页面加载完毕的问题
- JS实现弹出层锁定窗口(改进版)
- oracle中字段char、varchar和varchar2的区别