📜  从向量中选择随机元素而不重复并添加到另一个向量 c++ - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:20.983000             🧑  作者: Mango

代码示例1
#include 

vector  _myvec1{1,2,3,4,5,6};
vector  _myvec2{-5,-3,10,-8};

int n = 3;  //3 elements will be added
random_device rd;
mt19937 g(rd());

shuffle(_myvec2.begin(), _myvec2.end(), g);
for (int i=0; i