I'm trying to write a program that randomly picks n number of elements from a vector | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I'm trying to write a program that randomly picks n number of elements from a vector

i figured out to use a for loop to print a random index of the vector n times but how do i make it not repeat an index more than onece?

5th Apr 2018, 3:21 AM
Fig
Fig - avatar
1 Answer
+ 1
std::set<size_t> used_indices;
5th Apr 2018, 10:18 AM
Timon Paßlick