多做题,通过考试没问题!

艺术设计软件

睦霖题库>大学试题(计算机科学)>艺术设计软件

在Math类中random方法可以产生随机数。如果从1到100之间产生一个随机整数(大于等于1,小于等于100),并赋值给n,那么下面语句正确的是()。

  • A、n=Math.round(Math.random(100))+1;
  • B、n=Math.round(Math.random()*100)+1;
  • C、n=Math.floor(Math.random(100))+1;
  • D、n=Math.floor(Math.random()*100)+1;
正确答案:D
答案解析:
进入题库查看解析

微信扫一扫手机做题