UVa 10370 Above Average (Water ver.)

Source: Internet
Author: User
Tags integer time limit

10370-above Average

Time limit:3.000 seconds

Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem &problem=1311

It is said this 90% of Frosh expect to being above average in their class. You are are to provide a reality check.

The standard input contains an integer C, the number of test cases. C data sets follow. Each data set begins with an integer, n, the number of people in the class (1 <= N <= 1000). N integers follow, separated by spaces or newlines, each giving the final grade (an integer between 0 and) of a Studen T in the class. For each case you are to output a line giving the percentage of students whose grade are above average, rounded to 3 Decima L places.

Sample Input

5
5 of
7,
3
, 3, 9, 100, 99, 98 97, 96 95.

Output for Sample Input

40.000%
57.143%
33.333%
66.667%
55.556%

Complete code:

/*0.012s*/
  
#include <cstdio>
  
int num[1010];
  
int main (void)
{
    int i, T, N, average, count;
    scanf ("%d", &t);
    while (t--)
    {
        scanf ("%d", &n);
        Average = 0;
        for (i = 0; i < n; i++)
        {
            scanf ("%d", &num[i]);
            Average + = Num[i];
        }
        Average/= n;///because it is greater than, so no problem ~
        count = 0;
        for (i = 0; i < n; i++)
            if (Num[i] > average) count++;
        printf ("%.3f%%\n", (double) count/n *);
    return 0;
}

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.