Generate a random number less than 4 digits but the probability of it having 1, 2, or 3 digits is equal
I'm currently using (int)(rand() * 1000.0 / RAND_MAX) to generate a random number between 0 and 999 but the two and one digit numbers don't occur as often as the three digit numbers.
Aucun commentaire:
Enregistrer un commentaire