Skip to content

Instantly share code, notes, and snippets.

@tamanobi
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamanobi/37fc95dfe4b861a01c7d to your computer and use it in GitHub Desktop.
Save tamanobi/37fc95dfe4b861a01c7d to your computer and use it in GitHub Desktop.
C++で、与えられた2つの配列から共通集合を取り出す
#include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
int primary[] = { 1, 2, 4, 3, 5, 7, 11, 13 };
int number[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
int result[256];
int* ret;
ret = std::set_intersection(number, number + 15,
primary, primary + 7,
result);
for (int* p = result; p != ret; p++)
cout << *p << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment