Generate random numbers using C++11 random library

后端 未结 6 726
梦毁少年i
梦毁少年i 2020-11-22 15:13

As the title suggests, I am trying to figure out a way of generating random numbers using the new C++11 library. I have tried it with this code:<

6条回答
  •  粉色の甜心
    2020-11-22 15:43

    Here is some resource you can read about pseudo-random number generator.

    https://en.wikipedia.org/wiki/Pseudorandom_number_generator

    Basically, random numbers in computer need a seed (this number can be the current system time).

    Replace

    std::default_random_engine generator;
    

    By

    std::default_random_engine generator();
    

提交回复
热议问题