📜  cpp 范围内的随机数 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:58.510000             🧑  作者: Mango

代码示例3
#include 
#include 
int main()
{
    std::random_device rd; // obtain a random number from hardware
    std::mt19937 gen(rd()); // seed the generator
    std::uniform_int_distribution<> distr(25, 63); // define the range

    for(int n=0; n<40; ++n)
        std::cout << distr(gen) << ' '; // generate numbers
}