vector set_union() /set_intersection【集合合并/交集】
来源:互联网 发布:食品零售数据 编辑:程序博客网 时间:2024/05/29 14:14
#include<iostream>#include<algorithm>#include<vector>#include<map>#include<set>#define ALL(x) x,x+5#define INS(x) x.begin()using namespace std;int f[5]={5,10,15,20,25};int s[5]={50,40,30,20,10};void put(){ for(int i=0;i<5;i++) cout<<f[i]<<" "; cout<<endl; for(int i=0;i<5;i++) cout<<s[i]<<" "; cout<<endl;}int main(){ vector<int> v(10); //并不知道开多大的空间 最后可以用 v.resize(it-INS(v)); 收场 vector<int>::iterator it; sort(f,f+5); sort(s,s+5); put(); //输出当前排好序的两个数组 //it=set_union(ALL(f),ALL(s),INS(v)); // 5 10 15 20 25 30 40 50 0 0 it=set_intersection(ALL(f),ALL(s),INS(v)); //10 20 0 0 0 0 0 0 0 0 v.resize(it-INS(v)); //改变v容器的大小 cout<<v.size()<<endl; for(it=v.begin();it!=v.end();++it) cout<<*it<<" "; cout<<endl; return 0;}
阅读全文
0 0
- vector set_union() /set_intersection【集合合并/交集】
- set_union set_intersection
- 泛型算法:有序集合set_union和set_intersection
- C++集合运算函数总结-merge、set_union、set_difference、set_symmetric_difference、set_intersection
- set_union,set_intersection,set_difference,set_symmetric_difference
- C++ set_union,set_intersection,set_difference
- C++集合操作之集合交集:std::set_intersection
- C++集合操作之集合交集:std::set_intersection
- STL set_difference set_intersection set_union 操作
- C++ STL merge,set_union,set_intersection,set_difference,set_symmetric_difference
- STL 之includes,set_intersection,set_union,set_difference,set_symmetric_difference
- STL 之includes,set_intersection,set_union,set_difference,set_symmetric_difference
- STL之set_union、set_intersection、set_difference、set_symmetric_difference
- 合并有交集的集合
- 泛型算法系列35:set_difference()&&set_intersection()&&set_symmetric_difference()&&set_union()
- 给定一系列字符串集合,合并有交集的集合,合并完后集合之间无交集
- 将多个集合合并成没有交集的集合
- 将多个集合合并成没有交集的集合
- C++ Primer 中文版(第5版) 习题答案
- 《Win32多线程程序设计》CRT中的多线程
- IOS ——地图里NSString转为CLLocationDegrees类型
- [lcm] Qualcomm平台的显示屏lcd驱动移植步骤
- LeetCode简易题解--053
- vector set_union() /set_intersection【集合合并/交集】
- [lcm] Qualcomm Android Display Subsystem 架构
- java多线程并发
- centos6.6安装windows字体
- sqoop数据导入与数据导出
- 【每日一句shell】找出文件中大于5的数字
- ZOJ
- 文章标题
- 深夜切题——诸葛给我牌