题目描述
成绩分析
小蓝给学生们组织了一场考试,卷面总分为 100 分,每个学生的得分都是
一个 0 到 100 的整数。
请计算这次考试的最高分、最低分和平均分。
输入格式
输入的第一行包含一个整数 n,表示考试人数。
接下来 n 行,每行包含一个 0 至 100 的整数,表示一个学生的得分。
输出格式
输出三行
第一行包含一个整数,表示最高分。
第二行包含一个整数,表示最低分。
第三行包含一个实数,四舍五入保留正好两位小数,表示平均分。
input:
7
80
92
56
74
88
99
10
Output:
99
10
71.29
解题思路
package timeProblem;
import java.util.Scanner;
public class Main {
static int a[]=new int[100000];
public static void main(String[] args) {
int n,sum=0,max=0,min=100;
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
for(int i=0;i<n;i++) {
a[i]=sc.nextInt();
sum+=a[i];
if(a[i]>max)
max=a[i];
if(a[i]<min)
min=a[i];
}
System.out.println(max);
System.out.println(min);
System.out.printf("%.2f",(double)sum/n);
sc.close();
}
}