首页 > 代码库 > UVA-10370

UVA-10370

/********************************************************************@file     Main_practise.cpp@date     2014-8-22@author   Tiger@brief    Problem D: Above Average********************************************************************/#include <cstdio>//#define OJint 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;}