samedi 9 juin 2018

Algorithm to generate N numbers with rand() without duplicates

Is there an algorithm to generate an array containing all the numbers up to N, while using the rand() function?

The problem is that rand() can return the same number, so I need a trick to avoid that.(Meaning generating the numbers in one go, without using the rand() function more than N time)

Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire