Illustrate set_intersection : set_intersection « STL Algorithms Merge « C++ Tutorial






#include <iostream>
#include <cassert>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
  bool result;

  string s("abcde");
  string s2("aeiou");

  vector<char> vector1(s.begin(), s.end());
  vector<char> vector2(s2.begin(), s2.end());

  
  vector<char> setIntersection;
  set_intersection(vector1.begin(), vector1.end(),vector2.begin(), vector2.end(),back_inserter(setIntersection));

  for(int i=0;i<setIntersection.size();i++){
    cout << setIntersection[i];
  }

  return 0;
}
ae








28.5.set_intersection
28.5.1.Illustrate set_intersection
28.5.2.Intersect the ranges by using set_intersection()
28.5.3.Determine elements in both two sets