package day06;
import java.util.Scanner;
public class T10 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] arr = new int[6];
for (int i = 0; i < arr.length; i++) {
System.out.println("请输入第" + (i + 1) + "个分数");
arr[i] = sc.nextInt();
}
int max=getMax(arr);
int min=getMin(arr);
int sum=getSum(arr);
int a=(sum-max-min)/4;
System.out.println("最高分:"+max);
System.out.println("最低分:"+min);
System.out.println("总分:"+sum);
System.out.println("得分:"+a);
}
public static int getMax(int[] arr) {
int max = 0;
for (int i = 1; i < arr.length; i++) {
if (max < arr[i]) {
max = arr[i];
}
}
return max;
}
public static int getMin(int[] arr) {
int min = 0;
for (int i1 = 1; i1 < arr.length; i1++) {
if (min > arr[i1]) {
min = arr[i1];
}
}
return min;
}
public static int getSum(int[] arr) {
int sum = 0;
for (int i2 = 0; i2 < arr.length; i2++) {
sum += arr[i2];
}
return sum;
}
} |
|