-
Notifications
You must be signed in to change notification settings - Fork 96
/
2.9.cpp
32 lines (29 loc) · 1.02 KB
/
2.9.cpp
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
/*
* 题目名称:Grading
* 题目来源:浙江大学复试上机题
* 题目链接:http://t.cn/E9rDPSq
* 代码作者:杨泽邦(炉灰)
*/
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
int perfect, tolerance, grade1, grade2, grade3, gradeJudge;
while (cin >> perfect >> tolerance >> grade1 >> grade2 >> grade3 >> gradeJudge) {
double answer;
if (abs(grade1 - grade2) <= tolerance) {
answer = (grade1 + grade2) / 2.0;
} else if (abs(grade1 - grade3) <= tolerance && abs(grade2 - grade3) > tolerance) {
answer = (grade1 + grade3) / 2.0;
} else if (abs(grade2 - grade3) <= tolerance && abs(grade1 - grade3) > tolerance) {
answer = (grade2 + grade3) / 2.0;
} else if (abs(grade1 - grade3) <= tolerance && abs(grade2 - grade3) <= tolerance) {
answer = max(max(grade1, grade2), grade3);
} else {
answer = gradeJudge;
}
printf("%.1f\n", answer);
}
return 0;
}