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

Answer: How to generate a random number in C ?

Susan Sarandon
Release: 2024-10-08 14:09:02
Original
990 people have browsed it

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;
Copy after login
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!

source:dev.to
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template