Home >Backend Development >C++ >Answer: How to generate a random number in C ?
It's a good answer!
Using modulo may introduce bias into the random numbers, depending on the random number generator. See this question for more info. Of course, it's perfectly possible to get repeating numbers in a random sequence.
Try some C 11 features for better distribution:
#include <random> #include <iostream> int main() { std::random_device dev;…
The above is the detailed content of Answer: How to generate a random number in C ?. For more information, please follow other related articles on the PHP Chinese website!