按照题目要求编写的求平均分的Java程序如下:
import java.util.Scanner;
import java.util.Arrays;
public class F {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int a[]=new int[n];
for(int i=0;i
a[i]=sc.nextInt();
}
Arrays.sort(a);
int sum=0;
for(int i=1;i
sum=sum+a[i];
}
System.out.println(sum/(n-2));
}
}
Scannner scanner = new Scanner(System.in);
int N = scanner.nextInt();
int[] nums = new int[N];
for(int i = 0; i
}
//导入Arrays所在的包
Arrays.sort(nums);
int sum = 0;
for(int j=0;j
}
int avg = sum/nums.length-2;