java 有一组数{10,30,11,8,20,19,6,31}将该组数放入数组,并求出该
java有一组数{10,30,11,8,20,19,6,31}将该组数放入数组,并求出该数组中数字的最大值,最小值,平均值。。。。。详细...
java 有一组数{10,30,11,8,20,19,6,31}将该组数放入数组,并求出该数组中数字的最大值,最小值,平均值。。。。。详细
展开
2个回答
展开全部
public static void main(String[] args){
int[] a = {10,30,11,8,20,19,6,31};
int sum = 0;
int min = a[0];
int max = a[0];
int average = 0;
for(int i = 0; i < a.length; i++){
sum = sum + a[i];
if(a[i] < min)
min = a[i];
if(a[i] > max)
max = a[i];
}
average = sum/a.length;
}
int[] a = {10,30,11,8,20,19,6,31};
int sum = 0;
int min = a[0];
int max = a[0];
int average = 0;
for(int i = 0; i < a.length; i++){
sum = sum + a[i];
if(a[i] < min)
min = a[i];
if(a[i] > max)
max = a[i];
}
average = sum/a.length;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询