九度OJ 1002 Grading

题目描述:
Grading hundreds of thousands of Graduate Entrance Exams is a hard work. It is even harder to design a process to make the results as fair as possible. One way is to assign each exam problem to 3 independent experts. If they do not agree to each other, a judge is invited to make the final decision. Now you are asked to write a program to help this process.
For each problem, there is a full-mark P and a tolerance T(

#include <cstdio>
using namespace std;
/*
20 2 15 13 10 18
18 2 18 15 16 17
18 2 18 15 17 29
18 1 19 23 21 22
*/
double abs(double x){
    return x >= 0 ? x : -x;
}
int main(){
    char buffer[256];
    while(gets(buffer)){
        double P,T,G1,G2,G3,GJ;
        double result;
        sscanf(buffer,"%lf %lf %lf %lf %lf %lf",&P,&T,&G1,&G2,&G3,&GJ);
        if(abs(G1 - G2) <= T){
            result = (G1 + G2)/2;
        }else{
            int state = 0;
            if(G3 <= G1+T && G3 >= G1-T)state += 1;
            if(G3 <= G2+T && G3 >= G2-T)state += 2;
            switch(state){
                case 0:{result = GJ;
                        break;}
                case 1:{result = (G1 + G3)/2;
                        break;}
                case 2:{result = (G3 + G2)/2;
                        break;}
                case 3:{result = (G1 >= G1)? G1 : G2;
                        break;}
            }
        }
        printf("%.1f\n",result);
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值