码迷,mamicode.com
首页 > 其他好文 > 详细

UVA-10370

时间:2014-08-22 10:36:16      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   for   ar   2014   div   

/********************************************************************
@file     Main_practise.cpp
@date     2014-8-22
@author   Tiger
@brief    Problem D: Above Average
********************************************************************/
#include <cstdio>
//#define OJ

int main(int argc, const char* argv[])
{

#ifdef OJ
    freopen("input.txt", "r", stdin);
#endif

    int nTestCases = 0;
    scanf("%d", &nTestCases);
    while (nTestCases--)
    {
        int nStudents = 0;
        scanf("%d", &nStudents);

        double* pStudentScores = new double[nStudents];
        double fTotalScore = 0;
        for (int i=0; i<nStudents; ++i)
        {
            scanf("%lf", &pStudentScores[i]);
            fTotalScore += pStudentScores[i];
        }
        
        double fAverageScore = fTotalScore / nStudents;
        int nGoodStudents = 0;
        for (int i=0; i<nStudents; ++i)
        {
            if (pStudentScores[i] > fAverageScore)
            {
                ++nGoodStudents;
            }
        }

        double fAboveAverage = (static_cast<double>(nGoodStudents) / nStudents)*100;
        printf("%.3f%%\n", fAboveAverage);
    }

    return 0;
}

 

UVA-10370,布布扣,bubuko.com

UVA-10370

标签:style   blog   color   io   for   ar   2014   div   

原文地址:http://www.cnblogs.com/roronoa-zoro-zrh/p/3928574.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!