objective c - Random number from a range without a certain number in the middle of the range -


i'm generating number 0 11 randomly this:

int n = arc4random() % 12; 

but, i'd not 5 or 6 output. how can that?

if have such constraint, make explicit in code:

int n; {     n = arc4random() % 12; } while (n == 5 || n == 6); //retry if encountered 1 of unallowable values 

Comments

Popular posts from this blog

C# random value from dictionary and tuple -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -

cgi - How do I interpret URLs without extension as files rather than missing directories in nginx? -