c++获取浮点数随机数

2021-03-18 12:25

阅读:473

标签:color   orm   for   distrib   iostream   div   cout   sig   standard   

#include 
#include int main()
{
    std::random_device rd;  //Will be used to obtain a seed for the random number engine
    std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
    std::uniform_real_distribution dis(1.0, 2.0);
    for (int n = 0; n 10; ++n) {
        // Use dis to transform the random unsigned int generated by gen into a 
        // double in [1, 2). Each call to dis(gen) generates a new random double
        std::cout ‘ ;
    }
    std::cout \n;
}

 

c++获取浮点数随机数

标签:color   orm   for   distrib   iostream   div   cout   sig   standard   

原文地址:https://www.cnblogs.com/iwana/p/13915594.html


评论


亲,登录后才可以留言!