-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGrading.cpp
36 lines (34 loc) · 946 Bytes
/
Grading.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
33
34
35
36
#include <iostream>
#include <math.h>
#include <algorithm>
#include <cstdio>
using namespace std;
int main(int argc, char const *argv[])
{
float p, t, g1, g2, g3, gj, result;
cin >> p >> t >> g1 >> g2 >> g3 >> gj;
if (abs(g1 - g2) <= t) // case1
{
result = (g1 + g2) / 2;
printf("%.1f\n", result);
}
else
{
if ((abs(g1 - g3) < t || abs(g2 - g3) < t) && (t - abs(g1 - g3)) * (t - abs(g1 - g2)) < 0)
{ // 有一个在公差范围内
result = min((g1 + g3) / 2, (g2 + g3) / 2);
printf("%.1f\n", result);
}
if (abs(g1 - g3) < t && abs(g2 - g3) < t)
{
result = max(max(g1, g2), max(g2, g3));
printf("%.1f\n", result);
}
if (abs(g1 - g3) > t && abs(g2 - g3) > t)
{
result = gj;
printf("%.1f\n", result);
}
}
return 0;
}