标签:
1 #include "set" 2 #include "vector" 3 #include <algorithm> 4 using namespace std; 5 6 int main(void) 7 { 8 int iarr1[]={1,2,3,3,4,5,6,7,9}; 9 int iarr2[]={1,4,3,9,10}; 10 multiset<int> iset1(begin(iarr1),end(iarr1)); 11 multiset<int> iset2(begin(iarr2),end(iarr2)); 12 vector<int> ivec(20); 13 auto iter=set_intersection(iset1.begin(),iset1.end(),iset2.begin(),iset2.end(),ivec.begin()); //ivec为:1,3,4,9 14 ivec.resize(iter-ivec.begin());//重新确定ivec大小 15 for (auto it = ivec.begin(); it != ivec.end(); it ++) { 16 17 int d = *it; 18 printf("%d",d); 19 } 20 system("pause"); 21 return 0; 22 }
标签:
原文地址:http://www.cnblogs.com/gaohai/p/5796354.html