mercredi 13 mai 2020

Generating a random number within a range c++ [duplicate]

I'm trying to generate a random number between 20 and 54. The code I'm currently using is

y=  rand() % 34 + 20;

However each time I reset the programme the numbers generated are the same again, and is it possible to generate numbers within that range, but so each concurrent number is not within 5 of the number before?




Aucun commentaire:

Enregistrer un commentaire