dimanche 15 février 2015

How does Rand work when starting at a number(36) with a max of 75

I am creating a random number generator and whenever I run the current code block I always get a few numbers that go over the intended limit. The way it works is that I have a set of numbers that are randomly generated that go from 36-75, With adjusted numbers that are 5 higher and 5 lower than the original number. For example I will end up with numbers above 75. The highest being 105. Here is just one of the 6 numbers.



//Displays picks for Number 4
pick4 = (rand() % 75) + 36;
if (pick4 == pick3)
pick4 = (rand() % 75) + 36;
if (pick4 + 5 < 75 + 1)
{
if (pick4 - 5 > 0)
{
adjHighPick4 = pick4 + 5;
adjLowPick4 = pick4 - 5;
}
}

Aucun commentaire:

Enregistrer un commentaire