Last active
August 29, 2015 14:14
-
-
Save tamanobi/37fc95dfe4b861a01c7d to your computer and use it in GitHub Desktop.
C++で、与えられた2つの配列から共通集合を取り出す
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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