题解 | #统计成绩#
统计成绩
https://www.nowcoder.com/practice/cad8d946adf64ab3b17a555d68dc0bba
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n=in.nextInt(); double[] score=new double[n]; double sum=0.0; double max=score[0]; double min=100; for(int i=0;i<n;i++){ score[i]=in.nextDouble(); } for(int j=0;j<score.length;j++){ if(score[j]>max){ max=score[j]; } if(score[j]<min){ min=score[j]; } sum+=score[j]; } double aver; aver=(sum/n)*1.00; System.out.printf("%.2f %.2f %.2f",max,min,aver); } }