生成随机数1-10 (包含1和10)
结果是这样的:Math.floor(Math.random()*10+1) 那么问题又来了
Math.floor(Math.random()*10)生成的只是0-9的整数
生成0-10 怎么生成?
Math.floor(Math.random()*11) 啊啊啊啊啊.....然鹅我想了很久
不要把问题复杂化了,只是简单的数字游戏
不想要0 Math.random()*10+1 相当于(0,10] [1,10]
0和上限都不想要 Math.random()*(10-1)+1 相当于(0,10) [1,9]
不想要上限 Math.random()*10 相当于[0,10) [0,9]
想要0和上限 Math.random()*(10+1) 相当于[0,10] [0,11)