STL_Algorithm10: Set--集合操作
来源:互联网 发布:湖北自考网络助学加分 编辑:程序博客网 时间:2024/06/06 01:58
#include<iostream>
#include<algorithm>
#include<iterator>
using std::cout;
using std::endl;
int main()
{
const int SIZE1 = 10, SIZE2 = 5, SIZE3 = 20;
int a1[SIZE1] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int a2[SIZE2] = { 4, 5, 6, 7, 8 };
int a3[SIZE2] = { 4, 5, 6, 11, 15 };
std::ostream_iterator<int> outputIt( cout, " " );
cout<<"a1 contains: ";
std::copy( a1, a1 + SIZE1, outputIt );
cout<<"/na2 contains: ";
std::copy( a2, a2 + SIZE2, outputIt );
cout<<"/na3 contains: ";
std::copy( a3, a3 + SIZE2, outputIt );
if( std::includes( a1, a1 + SIZE1, a2, a2 + SIZE2 ) )
cout<<"/n/na1 includes a2";
else
cout<<"/n/na2 does not includes a2";
if( std::includes( a1, a1 + SIZE1, a3, a3 + SIZE2 ) )
cout<<"/n/na1 includes a3";
else
cout<<"/n/na1 does not includes a3";
int difference[SIZE1];
int* ptr = std::set_difference( a1, a1 + SIZE1, a2, a2 + SIZE2, difference );
cout<<"/n/nset_difference of a1 and a2 is: ";
std::copy( difference, ptr, outputIt );
int intersection[SIZE1];
ptr = std::set_intersection( a1, a1 + SIZE1, a2, a2 + SIZE2, intersection );
cout<<"/n/nset_intersection of a1 and a2 is: ";
std::copy( intersection, ptr, outputIt );
int symmetric_difference[ SIZE1 ];
ptr = std::set_symmetric_difference( a1, a1 + SIZE1, a3, a3 + SIZE2, symmetric_difference );
cout<<"/n/nset_symmetric_difference of a1 and a3 is: ";
std::copy( symmetric_difference, ptr, outputIt );
int unionSet[ SIZE3 ];
ptr = std::set_union( a1, a1 + SIZE1, a3, a3 + SIZE2, unionSet );
cout<<"/n/nset_union of a1 and a3 is: ";
std::copy( unionSet, ptr, outputIt );
cout<<endl;
return 0;
}
- STL_Algorithm10: Set--集合操作
- java集合Set操作
- Set集合操作
- python集合set操作
- python集合set操作
- Java Set集合操作
- Redis set集合操作
- Set集合常用操作
- redis集合set操作
- python set集合操作
- Delphi的set集合操作
- Python中的SET集合操作
- Python中的SET集合操作
- Python中的SET集合操作
- Python中的SET集合操作
- Python中的SET集合操作
- Python中的SET集合操作
- Set集合的基本操作
- MSComm控件注册
- c#实现双缓冲方法
- test1
- repair filesystem /etc/fstab readonly
- BSS段、数据段、代码段、堆与栈
- STL_Algorithm10: Set--集合操作
- 加入啦!!!!!!
- XML读取
- 设计模式的6大原则
- Linux内存管理(一)
- 为Qt程序添加资源文件
- 银行系统照片与本人不符 市民办理信贷业务遭拒
- 毕业论文评审意见、导师意见范文、模板
- Check Form