The rand () range is [0, RAND_MAX]
15.0 * rand () to get a floating point number,
Is 15 times [0, RAND_MAX], [0.0, 15.0 * RAND_MAX],
15.0 * rand ()/RAND_MAX is [0.0, 15.0]
15.0 * rand ()/(RAND_MAX + 1.0) [0.0, 15.0)
(int) (15.0 * rand ()/(1.0) RAND_MAX +) 0... 14
CodePudding user response:
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.htmlI hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html