Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the uniformly distributed value of C++

Shulou Source: shulou.com Published: 2022-06-03 06:13:38 10月01日 Update

This article introduces the knowledge of "how to achieve C++ uniformly distributed values". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

# include

# include

Whole Lord ()

{

Random device read; / / will be used to obtain the seeds of the random number engine

Mt19937 generates (read ()); / / to read () seeded standard Mason cyclone engine

Standard:: uniform real distribution is not (1, 2)

For (whole n = 0; n < 10; + + n) {

/ / the random positive integral generated by non-transformation is transformed into the double essence in [1,2).

Output

Tags: Generation output uniformity engine ratio seed random number numerical value clockwise content variable cyclone time more standard knowledge equipment Mason transformation utility Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi vpn OPPO Reno Shulou Information Apple