"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > Answer: How to generate a random number in C++?

Answer: How to generate a random number in C++?

Published on 2024-11-06
Browse:531

It's a good answer!

Answer: How to generate a random number in C  ? answer re: How to generate a random number in C ?
Answer: How to generate a random number in C  ?
336
Answer: How to generate a random number in C  ?

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 
#include 

int main()
{
    std::random_device dev;
Open Full Answer
Release Statement This article is reproduced at: https://dev.to/su_jack_4c3960e0a31b0a4af/answer-how-to-generate-a-random-number-in-c-3282 If there is any infringement, please contact [email protected] to delete it
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3