int main(void)
{
int iarr1[]={1,2,3,3,4,5,6,7};
int iarr2[]={1,4,3,3,3,7,8,9,10};
std::sort(begin(iarr1),end(iarr1));
std::sort(begin(iarr2),end(iarr2));
vector<int> ivec(20);
auto iter=set_union(begin(iarr1),end(iarr1),begin(iarr2),end(iarr2),ivec.begin()); //ivec为:1,2,3,3,3,4,5,6,7,8,9,10
ivec.resize(iter-ivec.begin());//重新确定ivec大小
return 0;
}
C++集合求并集 | set_union
CPP相关文章
最近热门
最常浏览
- 016 推荐系统 | 排序学习(LTR - Learning To Rank)
- 偏微分符号
- i.i.d(又称IID)
- 利普希茨连续条件(Lipschitz continuity)
- (error) MOVED 原因和解决方案
- TextCNN详解
- 找不到com.google.protobuf.GeneratedMessageV3的类文件
- Deployment failed: repository element was not specified in the POM inside distributionManagement
- cannot access com.google.protobuf.GeneratedMessageV3 解决方案
- CLUSTERDOWN Hash slot not served 问题原因和解决办法
×