题解 | #统计成绩#
统计成绩
https://www.nowcoder.com/practice/cad8d946adf64ab3b17a555d68dc0bba
import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); // 注意 hasNext 和 hasNextLine 的区别 while (in.hasNextInt()) { // 注意 while 处理多个 case int num = in.nextInt(); Double[] sco0 = new Double[num]; // 动态初始化 for(int i = 0 ; i < num; i++){ sco0[i] = in.nextDouble(); } Double max = sco0[0]; Double min = sco0[0]; Double sum = sco0[0]; for(int i = 1; i < sco0.length; i++){ if(max < sco0[i]){ max = sco0[i]; } if(min > sco0[i]){ min = sco0[i]; } sum += sco0[i]; } System.out.printf("%.2f %.2f %.2f",max,min,sum/num); } } }