首页 > 其他 > 详细

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

时间:2017-04-15 00:25:49      阅读:193      评论:0      收藏:0      [点我收藏+]

题目链接: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\n",score());
    }
}
/**************************************************************
    Problem: 1002
    User: zpfbuaa
    Language: C++
    Result: Accepted
    Time:0 ms
    Memory:1520 kb
****************************************************************/

 

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

原文:http://www.cnblogs.com/zpfbuaa/p/6711256.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!