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

        }
    }

#考研#
全部评论

相关推荐

努力学习的小绵羊:我反倒觉得这种挺好的,给不到我想要的就别浪费大家时间了
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务