lundi 22 février 2016

which random generator should I choose for no repeat numbers in a sequence in c++

I am programming using c++11. The program is better compatible on mac, linux and windows, if possible. If not, the program should be work well on linux at least, and I would not consider mac and windows platform. I want to return random number sequence from [a, b]. The count might equal to b-a or less than b-a. Numbers in the sequence should be different with each other, e.g. 9 8 6 1 3 0 7 for [0, 10]. There should not be, like two 8 or three 1, duplicate numbers in it. Which random generator should I use? uniform_int_distribution? or uniform_real_distribution? Does uniform_real_distribution better than uniform_int_distribution? Or Is there any other possible ways? Do I have to create my own random number list like this Unique (non-repeating) random numbers in O(1). Thanks for your time.




Aucun commentaire:

Enregistrer un commentaire