set_intersection的用法

来源:互联网 发布:表情图片制作软件下载 编辑:程序博客网 时间:2024/05/16 19:15
#include <iostream>#include <algorithm>#include <vector>using namespace std;int main (void){    int first[] = {5,10,15,20,25};    int second[] = {50,40,30,20,10};    vector<int> v(10);    vector<int>::iterator it;    sort (first,first+5);     //  5 10 15 20 25    sort (second,second+5);   // 10 20 30 40 50    it = set_intersection (first, first+5, second, second+5, v.begin());    cout << "intersection has " << int(it - v.begin()) << " elements.\n";    return 0;}

 
原创粉丝点击