ios - Pick a random number but not the number 3 -


what add make still picks random number not number 3?

- (ibaction)button3 { {     int randomviews = rand() % 6;     label1.text = [nsstring stringwithformat:@"%i", randomviews]; } 

here's way single call rand(). since you're excluding 1 number range, request smaller range of numbers , replace generated 3's top number of previous range:

- (ibaction)button3 { {     int randomviews = rand() % 5;     if (randomviews == 3) {         randomviews = 5     }     label1.text = [nsstring stringwithformat:@"%i", randomviews]; } 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -