一维数组实验题:大奖赛现场统分。已知某大奖赛有n个选手参赛,m(m>2)个评委为参赛选手评分(最高10分,最低0分)。统分规则为:在每个选手的m个得分中,去掉一个最高分和一个最低分后,取平均分作为该选

简介: 一维数组实验题:大奖赛现场统分。已知某大奖赛有n个选手参赛,m(m>2)个评委为参赛选手评分(最高10分,最低0分)。统分规则为:在每个选手的m个得分中,去掉一个最高分和一个最低分后,取平均分作为该选

一维数组实验题:大奖赛现场统分。已知某大奖赛有n个选手参赛,m(m>2)个评委为参赛选手评分(最高10分,最低0分)。统分规则为:在每个选手的m个得分中,去掉一个最高分和一个最低分后,取平均分作为该选手的最后得分。要求编程实现:


(1)根据n个选手的最后得分,从高到低输出选手的得分名次表,以确定获奖名单;

(2)根据各选手的最后得分与各评委给该选手所评分数的差距,对每个评委评分的准确性和评分水准给出一个定量的评价,每位评委的评分方法:(10 -(评委对选手x的评分 - x的得分)^2 的累加和),从高到低输出各评委得分的名次表。

输入提示:

printf(“How many Athletes?”);

scanf("%d", &n); /* 输入选手人数 /

printf(“How many judges?”);

scanf("%d", &m); / 输入评委人数 */


printf("Order of Athletes:\n");          /* 选手得分排序 */                       
printf("Order of judges:\n");            /* 评委得分排序 */



/* 函数功能:统计参赛选手的得分 */

void CountAthleteScore(int sh[], float sf[], int n, float f[], int m)

printf("\nAthlete %d is playing.", i);

printf("\nPlease enter his number code:");

scanf("%d", &sh[i]);


for (j = 1; j <= m; j++) /* 第j个评委 */

{

printf(“Judge %d gives score:”, j);


    printf("Delete a maximum score:%.1f\n", max);
    printf("Delete a minimum score:%.1f\n", min);    /*去掉一个最高分和最低分*/


/* 函数功能:对分数从高到低排序 */

void Sort(int h[], float f[], int n)


/* 函数功能:打印名次表 */

void Print(int h[], float f[], int n)

printf(“order\tfinal score\tnumber code\n”);

printf("%5d\t%11.3f\t%6d\n", i, f[i], h[i]);


/* 函数功能:统计评委的得分 */

void CountJudgeScore(int ph[], float pf[], int m, float sf[], float f[], int n)


程序运行示例如下:

How many Athletes?5

How many judges?5

Scores of Athletes:

Athlete 1 is playing.

Please enter his number code:11

Judge 1 gives score:9.5

Judge 2 gives score:9.6

Judge 3 gives score:9.7

Judge 4 gives score:9.4

Judge 5 gives score:9.0

Delete a maximum score:9.7

Delete a minimum score:9.0

The final score of Athlete 11 is 9.500


Athlete 2 is playing.

Please enter his number code:12

Judge 1 gives score:9.0

Judge 2 gives score:9.2

Judge 3 gives score:9.1

Judge 4 gives score:9.3

Judge 5 gives score:8.9

Delete a maximum score:9.3

Delete a minimum score:8.9

The final score of Athlete 12 is 9.100


Athlete 3 is playing.

Please enter his number code:13

Judge 1 gives score:9.6

Judge 2 gives score:9.7

Judge 3 gives score:9.5

Judge 4 gives score:9.8

Judge 5 gives score:9.4

Delete a maximum score:9.8

Delete a minimum score:9.4

The final score of Athlete 13 is 9.600


Athlete 4 is playing.

Please enter his number code:14

Judge 1 gives score:8.9

Judge 2 gives score:8.8

Judge 3 gives score:8.7

Judge 4 gives score:9.0

Judge 5 gives score:8.6

Delete a maximum score:9.0

Delete a minimum score:8.6

The final score of Athlete 14 is 8.800


Athlete 5 is playing.

Please enter his number code:15

Judge 1 gives score:9.0

Judge 2 gives score:9.1

Judge 3 gives score:8.8

Judge 4 gives score:8.9

Judge 5 gives score:9.2

Delete a maximum score:9.2

Delete a minimum score:8.8

The final score of Athlete 15 is 9.000

Order of Athletes:

order final score number code

1 9.600 13

2 9.500 11

3 9.100 12

4 9.000 15

5 8.800 14

Order of judges:

order final score number code

1 9.980 1

2 9.960 2

3 9.900 3

4 9.860 4

5 9.590 5

Over!Thank you!


#include <stdio.h>
#include <math.h>
void  CountAthleteScore(int sh[], float sf[], int n, float f[][10], int m); /* 函数功能:统计参赛选手的得分 */
void Sort(int h[], float f[], int n); /* 函数功能:对分数从高到低排序 */
void Print(int h[], float f[], int n); /* 函数功能:打印名次表 */
void CountJudgeScore(int ph[], float pf[], int m, float sf[], float f[][10],  int n); /* 函数功能:统计评委的得分 */
int main()
{
    int n,m,sh[10],ph[10];                          //sh[]选手编号,ph[]评委编号
    float sf[10],f[10][10],pf[10];                            //f[]每个评委给选手打分,sf[]每个选手最终得分,pf[]评委得分
    printf("How many Athletes?");
    scanf("%d", &n);                                /* 输入选手人数 */
    printf("How many judges?");
    scanf("%d", &m);                              /* 输入评委人数 */
    printf("Scores of Athletes:\n");
    CountAthleteScore(sh,sf,n,f,m);
    CountJudgeScore(ph,pf,m,sf,f,n);
    Sort(sh,sf,n);                                 //选手成绩排序
    printf("Order of Athletes:\n");          /* 选手得分排序 */
    Print(sh,sf,n);                                //选手排名打印
    printf("Order of judges:\n");            /* 评委得分排序 */
    Sort(ph,pf,m);
    Print(ph,pf,m);
    printf("Over!Thank you!");
    return 0;
}
void  CountAthleteScore(int sh[], float sf[], int n, float f[][10], int m)
{
    int i,j,k,g,t,w,e;
    float s,max,min;
    for(i=0;i<n;i++)
    {
        printf("\nAthlete %d is playing.", i+1);
        printf("\nPlease enter his number code:");
        scanf("%d", &sh[i]);
        for (j = 0; j < m; j++)              //录入成绩
        {
            printf("Judge %d gives score:", j+1);
            scanf("%f",&f[i][j]);
            getchar();
        }
        max=f[i][0];
        w=0;
        for(g=1;g<m;g++)
        {
            if(max<f[i][g])
            {
                max=f[i][g];
                w=g;//记录最高分标号
            }
        }
        min=f[i][0];
        e=0;
        for(t=1;t<m;t++)
        {
            if(min>f[i][t])
            {
                min=f[i][t];
                e=t;//记录最低分标号
            }
        }
        printf("Delete a maximum score:%.1f\n", max);
        printf("Delete a minimum score:%.1f\n", min);    /*去掉一个最高分和最低分*/
        s=0;
        for(k=0;k<m;k++)          //计算最终得分
        {
            if(k!=w&&k!=e)
                s+=f[i][k];
        }
        sf[i]=s/(m-2);
        printf("The final score of Athlete %d is %.3f\n",sh[i],sf[i]);
    }
}
void Sort(int h[], float f[], int n)
{
    int i,j;
    float t;
    for(i=0;i<n-1;i++)
    {
        for(j=i+1;j<n;j++)
        {
            if(f[i]<f[j])
            {
                t=f[i];
                f[i]=f[j];      //交换成绩
                f[j]=t;
                t=h[i];
                h[i]=h[j];      //交换编号
                h[j]=t;
            }
        }
    }
}
void Print(int h[], float f[], int n)
{
    int i;
    printf("order\tfinal score\tnumber code\n");
    for(i=0;i<n;i++)
    {
        printf("%5d\t%11.3f\t%6d\n", i+1, f[i], h[i]);
    }
}
void CountJudgeScore(int ph[], float pf[], int m, float sf[], float f[][10],  int n)
{
    int i,j;
    float s,t;
    for(i=0;i<m;i++)
    {
        s=0;
        for(j=0;j<n;j++)
        {
            t=(f[j][i]-sf[j])*(f[j][i]-sf[j]);
            s+=t;
        }
        pf[i]=10-s;
        ph[i]=i+1;
    }
}
相关文章
|
6月前
|
机器学习/深度学习 C语言 C++
【C++】——阶段性测验(帮助巩固C++前半部分知识)
【C++】——阶段性测验(帮助巩固C++前半部分知识)
|
5月前
|
搜索推荐 算法 C++
蓝桥杯分糖果、最小化战斗力差距、小蓝零花钱
这是一个关于算法问题的集合,包括三个不同的任务: 1. **分糖果**:肖恩有不同种类的糖果要分给学生,目标是使得到糖果字符串的字典序最大且尽量小。给定糖果种类数和一个初始字符串,输出能达到的最小字典序的最大值。 2. **最小化战斗力差距**:小蓝需要将队员分为两组,每组战斗力差距最小。给定队员数量和战斗力值,找出最小的战斗力差距。 3. **小蓝的零花钱**:小蓝要在序列中分割偶数和奇数,每次分割代价是两端元素差的绝对值。目标是在预算内确定最多能进行多少次这样的分割。 每个问题都提供了输入输出示例和相应的C++代码片段来解决这些问题。
|
5月前
1077 互评成绩计算 (20 分)
1077 互评成绩计算 (20 分)
|
5月前
1073 多选题常见计分法 (20 分)
1073 多选题常见计分法 (20 分)
某学科成绩的录入并显示出最高分,最低分,平均值。
某学科成绩的录入并显示出最高分,最低分,平均值。
|
算法
蓝桥杯 算法提高 统计平均成绩
蓝桥杯 算法提高 统计平均成绩
97 0
PTA 1077 互评成绩计算 (20 分)
在浙大的计算机专业课中,经常有互评分组报告这个环节。
159 0
|
测试技术
PAT乙级1004.成绩排名(20分)
PAT乙级1004.成绩排名(20分)
94 0
L2-015 互评成绩 (25 分)(sort)
L2-015 互评成绩 (25 分)(sort)
124 0
7-56 互评成绩 (25 分) (排序题)
7-56 互评成绩 (25 分) (排序题)
106 0