计算int数组中的最大,最小,平均值
public static void testNumber(int[] arr) {
int max = arr[0];
int min = arr[0];
int avg = 0;
int sum = 0;
for (int i = 0; i < arr.length; i++) {
if (arr[i] > max) {
max = arr[i];
}
if (arr[i] < min) {
min = arr[i];
}
sum += arr[i];
}
avg = sum / arr.length;
network.append("最大:" + max + "ms\n");
network.append("最小:" + min+ "ms\n");
network.append("平均:" + avg+ "ms\n");