题解 | #Grading#
Grading
https://www.nowcoder.com/practice/23e3244406724ffa8330760f640c8149
#include "cstdio" #include "iostream" #include "cmath" using namespace std; int main() { double P, T, G1, G2, G3, GJ; double G12, G13, G23; //对G1,G2,G3分别求差值 scanf("%lf %lf %lf %lf %lf", &P, &T, &G1, &G2, &G3, &GJ); G12 = fabs(G1 - G2); G23 = fabs(G3 - G2); G13 = fabs(G3 - G1); if (G12 <= T) { printf("%.1f\n", (G1+G2)/2.0); } else if (G13 <= T && G23 <= T) { printf("%.1lf\n", max(G1, max(G2, G3))); } else if (G13 <= T || G23 <= T) { printf("%.1lf\n", min(G13 - T, G23 - T)); } else { printf("%.1lf\n", GJ); } }#考研#