• 题目1002:Grading(题目背景基于高考打分的简单判断)


    题目链接:http://ac.jobdu.com/problem.php?pid=1002

    详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus

    参考代码:

    //
    //  1002 Grading.cpp
    //  Jobdu
    //
    //  Created by PengFei_Zheng on 2017/4/14.
    //  Copyright © 2017年 PengFei_Zheng. All rights reserved.
    //
     
    #include <stdio.h>
    #include <iostream>
    #include <algorithm>
    #include <string.h>
    #include <cmath>
     
    using namespace std;
     
    double p,t,g1,g2,g3,gj;
     
    double score(){
        if(abs(g1-g2)<=t) return (g1+g2)/2;
        int abs1 = abs(g3-g1);
        int abs2 = abs(g3-g2);
        bool flag1 = abs1<=t ? true : false;
        bool flag2 = abs2<=t ? true : false;
        if(flag1 && !flag2) return (g3+g1)/2;
        if(flag2 && !flag1) return (g3+g2)/2;
        if(flag1 && flag2 ) return max(max(g1,g2),g3);
        else return gj;
    }
     
    int main(){
        while(scanf("%lf%lf%lf%lf%lf%lf",&p,&t,&g1,&g2,&g3,&gj)!=EOF){
            printf("%.1lf
    ",score());
        }
    }
    /**************************************************************
        Problem: 1002
        User: zpfbuaa
        Language: C++
        Result: Accepted
        Time:0 ms
        Memory:1520 kb
    ****************************************************************/
  • 相关阅读:
    nyoj 16 矩形嵌套
    nyoj 44 子串和
    nyoj 448 寻找最大数
    nyoj 14 会场安排问题
    hdoj 1008 Elevator
    bzoj1588
    bzoj3224
    bzoj1503
    bzoj1834
    bzoj1066
  • 原文地址:https://www.cnblogs.com/zpfbuaa/p/6711256.html
Copyright © 2020-2023  润新知