generating a random number within range 0 to n where n can be > RAND_MAX

前端 未结 9 2071
梦毁少年i
梦毁少年i 2021-01-18 08:32

How can I generate a random number within range 0 to n where n can be > RAND_MAX in c,c++?

Thanks.

9条回答
  •  悲哀的现实
    2021-01-18 08:43

    Assuming C++, have you tried looking at a decent random number library, like Boost.Random. Otherwise you may have to combine multiple random numbers.

提交回复
热议问题