choose random elements from vector without repetition and adding to another vector c++

The solution for “choose random elements from vector without repetition and adding to another vector c++” can be found here. The following code will assist you in solving the problem.

#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

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in