我写的代码
public class Demo6_6{
public static void main(String[] args){
int[] nums = new int[]{61, 23, 4, 74, 13, 148, 20};
int max = nums[0];
int min = nums[0];
int sum = 0;
double avg = 0;
for(int i = 0; i < nums.length; i++){
if(nums[i] > max){
max = nums[i];
}
else if(nums[i] < min){
min = nums[i];
}
sum = sum + nums[i];
}
avg = sum /nums.length;
System.out.println("最大值是" + max);
System.out.println("最小值是" + min);
System.out.println("平均值是" + avg);
System.out.println("总和是" + sum);
}
}