UVa 10370 Above Average (water ver.)

  • 阿里云国际版折扣https://www.yundadi.com

  • 阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6


    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 that 90% of frosh expect to be above average in their class. You are to provide a reality check.

    The first line of 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 100) of a student in the class. For each case you are to output a line giving the percentage of students whose grade is above average, rounded to 3 decimal places.

    Sample Input


    5
    5 50 50 70 80 100
    7 100 95 90 80 70 60 50
    3 70 90 80
    3 70 90 81
    9 100 99 98 97 96 95 94 93 91


    Output for Sample Input


    40.000%
    57.143%
    33.333%
    66.667%
    55.556%


    完整代码:

    /*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;///由于是大于,所以没问题~
    		count = 0;
    		for (i = 0; i < n; i++)
    			if (num[i] > average) count++;
    		printf("%.3f%%\n", (double)count / n * 100);
    	}
    	return 0;
    }



  • 阿里云国际版折扣https://www.yundadi.com

  • 阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

    “UVa 10370 Above Average (water ver.)” 的相关文章

    git clone 项目报错early EOF 的解决方式

    年后第一天开工拉取代码时遇到一个报错,early EOF,上网查说一般出现这种错误的原因是目标仓库太大了,顾尝试修改git缓存后重试: git config --global http.postBuffer 1048576000 将ht...

    2023浙江省赛“信息安全管理与评估“--Reverse部分全部解析(高职组)

    2022全国职业技能大赛“信息安全管理与评估”(高职组)任务书 2022全国职业技能大赛“信息安全管理与评估”任务书 第一阶段竞赛项目试题 第二阶段竞赛项目试题 第三阶段竞赛项目试题...

    Python怎么实现实时跟随微信窗口移动的GUI界面 - 开发技术

    本篇内容介绍了“Python怎么实现实时跟随微信窗口移动的GUI界面”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!Python写一些简单的GUI界面也是非常简单的,并且...

    定义PHP数组的方式是什么 - 编程语言

    这篇文章主要介绍“定义PHP数组的方式是什么”,在日常操作中,相信很多人在定义PHP数组的方式是什么问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”定义PHP数组的方式是什么”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!...

    linux

    1、APT主要命令 通过apt-get工具可使我们很好地解决软件包的依赖关系,方便软件的安装和升级apt-cache search  ——package 搜索包sudo apt-get install ——package 安装包sudo apt-get remove —–pack...

    Linux

     linux下杀死进程的N种方法 把ps的查询结果通过管道给grep查找包含特定字符串的进程。管道符“|”用来隔开两个命令,管道符左边命令的输出会作为管道符右边命令的输入。$ ps -ef | grep firefoxsmx       1827 &...