题解 | #统计成绩#
统计成绩
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); int num = in.nextInt(); double max = in.nextDouble(); double min = max; double avg = 0; double sum = max; while(in.hasNext()){ double temp = in.nextDouble(); max = max>=temp?max:temp; min = min<temp?min:temp; sum = sum+temp; } System.out.printf("%.2f %.2f %.2f",max,min,((sum)/num)); } }