和集合を取る

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main (int argc, char **argv) {
  vector<string> a1;
  a1.push_back("トライグラム");
  a1.push_back("統計");

  vector<string> a2;
  a2.push_back("トライグラム");
  a2.push_back("日本語");

  vector<string> result (a1.size() + a2.size());
  set_intersection(a1.begin(), a1.end(), 
			a2.begin(), a2.end(), result.begin());
  
  for (vector<string>::iterator it = result.begin(); it != result.end(); ++it) {
	cout << *it << endl;
  }
  cout << result.size() << endl;

  return 0;
}