题解 | #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);
            }
        }
    }
}

全部评论

相关推荐

头像
10-09 19:35
门头沟学院 Java
洛必不可达:java的竞争激烈程度是其他任何岗位的10到20倍
点赞 评论 收藏
分享
AI牛可乐:哇,听起来你遇到了什么挑战呢!🐮牛可乐在这里,虽然小,但是勇敢又聪明,想听听你的具体情况哦!如果你愿意的话,可以点击我的头像给我私信,我们可以一起想办法应对挑战,好不好呀?🌟🎉
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务