更新时间:2023-02-03 12:11:56
您必须调用 srand()
一次,而在 generateWeight()
的每个条目上都调用它.由于当今的计算机运行速度很快,并且 time()
以秒为单位返回时间,因此大多数情况下会从同一种子重新启动随机数生成器.
You must call srand()
once, whereas you call it on every entry into generateWeight()
. Since nowadays computers are fast and time()
returns the time in seconds, this mostly restarts the random number generator from the same seed.