摘要:
以生成[10,20]随机数为例,首先生成0-20的随机数,然后对(20-10+1)取模得到[0-10]之间的随机数,然后加上min=10,最后生成的是10-20的随机数 int num = random.nextInt(max)%(max-min+1)+min 得到min-max的左闭右闭区间的随机 阅读全文
posted @ 2020-09-03 11:08
coder小白
阅读(4939)
评论(0)
推荐(0)