srand is too slow in C++ it return same number

后端 未结 1 535
猫巷女王i
猫巷女王i 2021-01-29 08:07

I\'m just trying to have simply RndInt(limit) function that will return random numbers with a limit as limit.

    cout << \"Enter higher limit of random ra         


        
相关标签:
1条回答
  • 2021-01-29 08:24

    Do not call srand() every time you want a random number. Call srand() once at the start of your program, and then call rand() for each number.

    0 讨论(0)
提交回复
热议问题