#include <iostream>
#include <random>
#include <algorithm>
#include <time.h>
using namespace std;
int main()
{
// 乱数生成器を用意する
random_device rnd; // 非決定的な乱数生成器
mt19937 mt(rnd()); // メルセンヌ・ツイスタの 32 ビット版(疑似乱数生成器)
// 非決定的な乱数生成器で初期設定(以下の2行の方法でも可)
// mt19937 mt;
// mt.seed(rnd()); // 従来の方法:mt.seed((unsigned int)time(NULL));
// 抽出対象
cout << "抽出対象 v :";
vector<int> v1 = {0, 1, 2, 3, 4, 5};
for (auto x : v1)
cout << " " << x;
cout << endl;
// 3 個の要素を抽出
vector<int> v2;
sample(v1.begin(), v1.end(), back_inserter(v2), 3, mt); // back_inserter 参照
cout << "抽出された 3 個の要素 :";
for (auto x : v2)
cout << " " << x;
cout << endl;
// shuffle
shuffle(v1.begin(), v1.end(), mt);
cout << "v1 をシャッフル : ";
for (auto x : v1)
cout << " " << x;
cout << endl;
return 0;
}