-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMain.java
43 lines (37 loc) · 1.71 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.liaoguoyin.pat.团体程序设计天梯赛.L2015;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
/**
* L2-015 互评成绩 (25 分)
*/
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer stringTokenizer = new StringTokenizer(bufferedReader.readLine());
int studentCount = Integer.parseInt(stringTokenizer.nextToken());
int commentCount = Integer.parseInt(stringTokenizer.nextToken());
int outCount = Integer.parseInt(stringTokenizer.nextToken());
double[] averageResult = new double[studentCount];
for (int i = 0; i < studentCount; i++) {
int[] studentMarks = new int[commentCount];
stringTokenizer = new StringTokenizer(bufferedReader.readLine());
int sum = 0;
for (int j = 0; j < commentCount; j++) {
studentMarks[j] = Integer.parseInt(stringTokenizer.nextToken());
sum += studentMarks[j];
}
// 去掉最低分最高分,即排序后去掉下标为0和length - 1 的元素
Arrays.sort(studentMarks);
sum = sum - studentMarks[0] - studentMarks[studentMarks.length - 1];
averageResult[i] = sum / ((commentCount - 2) * 1.0);
}
Arrays.sort(averageResult);
for (int i = studentCount - outCount; i < studentCount - 1; i++) {
System.out.format("%.3f ", averageResult[i]);
}
System.out.format("%.3f", averageResult[studentCount - 1]);
}
}