题解 | #Grading#

Grading

https://www.nowcoder.com/practice/23e3244406724ffa8330760f640c8149

#include <algorithm>
#include <bits/stdc++.h>
#include <complex>
using namespace std;

int main() {
    int a, b,x,y,z,j;
    while (cin >> a >> b >>x >>y>>z>>j) { 
        
        double n = 0.0;

        if (abs(x-y)<=b) n = 1.0* (double)(x+y)/2;
        else if (abs(x-z)<=b && abs(z-y)<=b) n =  max(max(x, y),z)+0.0;
        else if (abs(x-z)<=b) n =  (double)(x+z)/2+0.0;
        else if (abs(y-z)<=b) n =  (double)(z+y)/2+0.0;
        else n =  (double)0.0+j;
         
        printf("%.1f\n", n); 
    }
}

 printf("%.1f\n", n); 

// 保留一位小数,其他没有要说明的

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务