What's wrong with my random number generator?

前端 未结 3 1671
借酒劲吻你
借酒劲吻你 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.

提交回复
热议问题