public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
DecimalFormat df = new DecimalFormat("0.00");
int x = sc.nextInt();
String a = null ;
int sum = 0;
int y ;
for (int i = 0; i <= x; i++) {
a = sc.nextLine();
}
String arr[] = a.split("nextLine");
int num[] = new int[arr.length];
for (int i = 0; i < num.length; i++) {
num[i] = Integer.parseInt(arr[i]);
for (int j = 0; j < num.length; j++) {
sum = sum + num[j];
}
System.out.println(df.format(sum/x));
}
}
a.split("nextLine") 你是要分隔什么呢?
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
DecimalFormat df = new DecimalFormat("0.00");
int x = sc.nextInt();
int sum = 0;
int num[] = new int[x];
for (int i = 0; i < x; i++) {
num[i] = sc.nextInt();
sum = sum + num[i];
}
System.out.println(df.format(sum*1.0/x));
}