输出数组最大值,最小值和平均值

[table]
||
[/table]public class MaxMin {

public static void main(String[] args) {

Integer[] inte = {12,23,54,75,86};
int max = inte[0];
int min = inte[0];
int average = 0;
int sum = 0;

for(int i=0;i if(max max = inte[i];
}
if(min>inte[i]){
min = inte[i];
}
sum += inte[i];
}
average = sum/inte.length;
System.out.println("最大值----"+max);
System.out.println("最小值----"+min);
System.out.println("平均值----"+average);

}

}

你可能感兴趣的:(输出数组最大值,最小值和平均值)