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
Post a Comment