What's wrong with my random number generator?

前端 未结 3 1681
借酒劲吻你
借酒劲吻你 2021-01-17 04:14

I\'m just diving into some C++ and I decided to make a random number generator (how random the number is, it really doesn\'t matter). Most of the code is copied off then net

3条回答
  •  借酒劲吻你
    2021-01-17 04:44

    Don't call srand() within random_number(). This will re-seed the random number generator every call. For 100 calls, you'll very likely get the same seed every call, and therefore the same number.

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题