11智能在线
新记
在java中使用Math函数的random()方法随机生成100个100以内的随机数,并求和输出。
求求求
举报该文章
其他看法
第1个回答 2020-06-01
class Test{
public static void main(String[] args){
int sum=0;
for(int x=1;x<=100;x++){
int item=(int)(Math.random()*100);
sum+=item;
}
System.out.println(sum);
}
}
相似回答
大家正在搜
相关问题
java 使用Math.random()产生一个100以内的...
java程序编写:使用Math类提供的随机数生成方法,产生一...
Java用Math.random()生成一个50-100间的...
java:通过方法Math.random()生成10个数值为...
JAVA中利用Random类产生两个100以内的随机数,计算...
JAVA随机生成100以内的随机数
java 使用Math.random()如何产生一个100以...
java 生成100以内10个不重复的随机数,用Math.r...