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

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

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