Math.floor(Math.random()*(m-n+1)+n) 其中m為隨機數的最大值,n為隨機數的最小值 如: Math.floor(Math.random() * (20 - 10 + 1) + 10); 生成1-50內的隨機整數 轉自:https://www.cnblogs.com/mmykd...