Home >Backend Development >C++ >Answer: How to generate a random number in C ?

Answer: How to generate a random number in C ?

Susan Sarandon
Susan SarandonOriginal
2024-10-08 14:09:02976browse

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

int main()
{
    std::random_device dev;
Open Full Answer

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn