0-100的 随机整数的获取办法有多种,下面是参考办法之一:

(int) (Math.random() * 100)

Math.random() 会得到一个0-1之间的随机浮点数,然后乘以100,并强转为整型即可。

eg:

[1,6]

(int)(Math.random()*(6-1+1)+1);

相关文章:

  • 2021-10-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-25
  • 2022-12-23
  • 2022-12-23
  • 2022-02-05
  • 2021-08-28
  • 2022-12-23
相关资源
相似解决方案