yanrun
public static void main(String[] args) {
int[] nums = new int[]{1, 2, 3, 4, 5, 6};
int max = nums[0];
int min = nums[0];
double sum = 0;
double avg = 0;
for (int i = 0; i < nums.length; i++) {
if (max < num) {
max = num;
}
if (min > num) {
min = num;
}
sum += num;
}
avg = sum / nums.length;
System.out.println("最大数为:" + max);
System.out.println("最小数为:" + min);
System.out.println("和为:" + sum);
System.out.println("平均数为:" + avg);
}