[sicily]1817. 校歌手大奖赛

来源:互联网 发布:淘宝助理安卓手机版5.7 编辑:程序博客网 时间:2024/04/28 06:19

1817. 校歌手大奖赛

Constraints

Time Limit: 1 secs, Memory Limit: 32 MB

Description

校歌手大奖赛中每个评委会给每个参赛选手打分,请用类描述每个选手的被评委的评分。选手得分规则为去掉一个最高分和一个最低分,然后计算平均得分,请编程输出某选手的得分。

 

Input

输入数据有多组,第一行为数据组数T

每组数据第一行两个正整数 n m (3 <= n,m <= 100),表示有 n 个 评 委 , m个选手。

接下来 n 行,每行 m 个正整数。每行表示一个评委给 m 个选手的分数,分数为[0,100]的整数。

 

Output

请将结果输出对于每组输入数据输出 m 行,每行表示一个选手的得分,结果保留 2 位小数。

 

Sample Input

13 41 2 3 41 2 3 41 2 3 4

Sample Output

1.002.003.004.00

简单数组元素处理题。根据题意对输入的二维数组每一列进行排序,然后去掉头尾求平均值,注意输出的格式要求。代码如下:

// Problem#: 1817// Submission#: 3947893// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/// All Copyright reserved by Informatic Lab of Sun Yat-sen University#include<stdio.h>#include<algorithm>using namespace std;int main(){       float t;    scanf("%f", &t);    while(t--)    {        int n,m;        int a[101][101];        scanf("%d%d", &n, &m);        for(int i=0; i<n; i++)        {            for(int j=0; j<m; j++)            {                scanf("%d", &a[i][j]);            }        }        int b[101];        for(int j=0; j<m; j++)        {                    float sum = 0;            for(int i=0; i<n; i++)            {                b[i] = a[i][j];            }            sort(b,b+n);            for(int i=1; i<n-1; i++)                sum += b[i];            printf("%.2lf\n", sum/(n-2));        }    }    //system("pause");    return 0;   }                                 


0 0
原创粉丝点击