#include <iostream>#include <vector>#include <algorithm> //sort function, orthogonal complement function#include <iterator> //finding iterators used by orthogonalusing namespacestd;//Print container vectorvoidPrint_vector (vector<int>v) { if(V.size () >0) {cout<<"{"; for(intI=0;i<int(V.size ()); i++) {cout<<v[i]<<","; } cout<<"\b}"; } Else{cout<<"{}"; }}//the de-weight of elements in a container vectorvector<int> Unique_element_in_vector (vector<int>v) {Vector<int>:: Iterator vector_iterator; Sort (V.begin (), V.end ()); Vector_iterator=Unique (V.begin (), V.end ()); if(Vector_iterator! =V.end ()) {V.erase (Vector_iterator,v.end ()); } returnv;}//two vectors to seek the intersection ofvector<int> Vectors_intersection (vector<int> v1,vector<int>v2) {Vector<int>v; Sort (V1.begin (), V1.end ()); Sort (V2.begin (), V2.end ()); Set_intersection (V1.begin (), V1.end (), V2.begin (), V2.end (), Back_inserter (v));//ask for intersection returnv;}//two vector and set of vectorsvector<int> Vectors_set_union (vector<int> v1,vector<int>v2) {Vector<int>v; Sort (V1.begin (), V1.end ()); Sort (V2.begin (), V2.end ()); Set_union (V1.begin (), V1.end (), V2.begin (), V2.end (), Back_inserter (v));//ask for intersection returnv;}//determine whether an element of a vector existsBOOLIs_element_in_vector (vector<int> V,intElement) {Vector<int>:: Iterator it; It=Find (V.begin (), v.end (), Element); if(it!=V.end ()) { return true; } Else{ return false; }}intmain () {vector<int>v1,v2,v; V1.push_back ( A); V1.push_back ( A); V1.push_back ( at); V2.push_back ( at); V2.push_back ( -); cout<<"is there a 1 element for v1? "<<is_element_in_vector (v1,1) <<Endl; cout<<"To v1 to the weight:"; V1=Unique_element_in_vector (v1); Print_vector (v1); cout<<Endl; cout<<"To seek the intersection of V1 and V2:"; V=vectors_intersection (V1,V2); Print_vector (v); cout<<Endl; cout<<"To seek the V1 and V2:"; V=vectors_set_union (V1,V2); Print_vector (v); return 0;}
"C + +" Determines whether the element is in the vector, the vector to the weight, two vectors to seek the intersection, and set