Array Generation with certain repeat

Oct 1, 2021 at 10:55am
Hello,
I have a small question. I need to assign the values from 1 to 10 by repeating each two times in random index. I generated an array with 20 index. Now, I need to assign the values for example like this:

[3 7 1 6 8 10 5 7 1 9 6 8 10 2 5 4 9 2 4 3]
How can I do this ?
Thank you so much


Last edited on Oct 1, 2021 at 10:55am
Oct 1, 2021 at 10:57am
Put all the values you want in an array and then shuffle them.

https://www.cplusplus.com/reference/algorithm/shuffle/
Last edited on Oct 1, 2021 at 10:59am
Oct 1, 2021 at 11:23am
Thank you so much @lastchance , the problem is solved
Topic archived. No new replies allowed.