java中任意M~N范围随机数
(M+(N-M)*Math.random())
若需整型,则
(int)(M+(N-M)*Math.random())
(最大值-最小值)*Math.random() + 最小值
如果要包含最大值,则最大值加1
(M+(N-M)*Math.random())
若需整型,则
(int)(M+(N-M)*Math.random())
(最大值-最小值)*Math.random() + 最小值
如果要包含最大值,则最大值加1
暂无评论。
评论功能维护中,当前仅展示历史评论。