在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);
}
}
相似回答