Created
April 26, 2014 16:29
-
-
Save beakr/11324520 to your computer and use it in GitHub Desktop.
Generate a random integer in a range with C++.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main(...) | |
{ | |
srand(time(NULL)); | |
while (true) { | |
int nmin = 220; | |
int nmax = 550; | |
int x = nmin + (std::rand() % (nmax - nmin + 1)); | |
printf("%i\n", x); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment