题解 | #Grading#
Grading
https://www.nowcoder.com/practice/23e3244406724ffa8330760f640c8149
//送分题,就是麻烦一点
#include "stdio.h"
#include "math.h"
#include "algorithm"
using namespace std;
int main(){
double F,T,G1,G2,G3,GJ;//full-mark,tolerance
while (scanf("%lf%lf%lf%lf%lf%lf",&F,&T,&G1,&G2,&G3,&GJ) != EOF){
double difference1 = fabs(G1-G2);
if(difference1 <= T){
printf("%.1lf\n",(G1+G2)/2);
continue;
} else {
double difference2 = G3-G1;
double difference3 = G3-G2;
if(difference2 <= T && difference3 <= T){
double max = G1>G2?G1:G2;
max = max>G3?max:G3;
printf("%.1lf\n",max);
continue;
} else if (difference2 <= T || difference3 <= T){
if (fabs(G3-G1) < fabs(G3-G2)){
printf("%.1ld\n",(G3+G1)/2);
continue;
} else{
printf("%.1ld\n",(G3+G2)/2);
continue;
}
} else{
printf("%.1lf\n",GJ);
}
}
}
}
查看14道真题和解析
