C++ random numbers

前端 未结 7 1133
生来不讨喜
生来不讨喜 2021-01-20 05:55

At the following: http://www.fredosaurus.com/notes-cpp/misc/random.html

It mentions that if we want to generate a random number in the range 1-10, we ca

7条回答
  •  甜味超标
    2021-01-20 06:22

    random without ++1 would make random number in range of 0-9 like array in C goes from 0 to n, same in here. Very first number is 0 so to get 1-10 you add minimal value (1).

提交回复
热议问题