jeudi 7 mai 2015

Generate random in [0, n)

Using <random> standard functions/classes/etc of C++11 how to generate random number in these ranges:

  • (n, m) - not including both ends
  • (n, m] - not including beginning
  • [n, m) - not including end

And special cases of them:

  • [0, n)
  • [0, 1)

Or may be there is any doc like cheat sheet for <random>?




Aucun commentaire:

Enregistrer un commentaire