1.实现
int[] arr = new int[10];
//赋值
for (int i = 0; i < arr.length; i++) {
arr[i] = (int)(Math.random()*90+10);
System.out.print(arr[i]+"/t");
}
int maxValue = arr[0];
int minValue = arr[0];
int sum = 0;
double avg = 0;
for (int i = 0; i < arr.length; i++) {
sum+=arr[i];
if (maxValue<arr[i]){
maxValue = arr[i];
}
if (minValue>arr[i]){
minValue = arr[i];
}
}
avg = sum*1.00/arr.length;
System.out.println("最大值"+maxValue);
System.out.println("最小值:"+minValue);
System.out.println("和为:"+sum);
System.out.println("平均:"+avg);
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/281687.html