
想知道这里应该怎么把随机数存进去?数组中的个数是键盘输入进去,根据元素个数产生随机数然后存入数组,这里不清楚具体怎么做?

关注math.random() 产生随机数,然后保存到数组,跟你输入是一样的呀

public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("请输入产生随机数个数:");
int count =scan.nextInt();
int a[]=new int [count];
for(int i=0;i<count;i++){
a[i]=(int) (Math.random() * 100);
}
Arrays.sort(a);
System.out.print("倒叙结果是"+"\t");
for(int i=count-1;i>=0;i--){
System.out.print(a[i]+"\t");
}
}