一维数组实验题:大奖赛现场统分。已知某大奖赛有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;
    }
}
相关文章
|
区块链
【photoshop】使用ps将图片另存为ico
【photoshop】使用ps将图片另存为ico
679 0
|
弹性计算 网络协议 测试技术
系统原因导致的丢包问题如何破?
丢包的问题经常碰到,那丢包的问题如何破?今天专家枫凡坐诊为您分析丢包问题,一个案例教你如何排查系统原因导致的丢包问题。
|
5月前
|
缓存 运维 前端开发
阿里云操作系统控制台:高效解决性能瓶颈与抖动之进程热点追踪
遇到“进程性能瓶颈导致业务异常”等多项业务痛点时,提供高效解决方案,并展示案例。
|
机器学习/深度学习 自然语言处理 PyTorch
【从零开始学习深度学习】34. Pytorch-RNN项目实战:RNN创作歌词案例--使用周杰伦专辑歌词训练模型并创作歌曲【含数据集与源码】
【从零开始学习深度学习】34. Pytorch-RNN项目实战:RNN创作歌词案例--使用周杰伦专辑歌词训练模型并创作歌曲【含数据集与源码】
【node】 cnpm|npm查看、修改镜像地址操作 换源操作
【node】 cnpm|npm查看、修改镜像地址操作 换源操作
4351 1
|
机器学习/深度学习 数据采集 监控
图像分类的发展历史、技术全解以及实战应用
图像分类的发展历史、技术全解以及实战应用
615 0
|
前端开发 JavaScript 数据处理
深入Python Web开发:模板引擎的力量与最佳实践
【7月更文挑战第21天】Python Web开发中,模板引擎如Jinja2促进MVC架构的View层,分离后端数据与前端展示,提升开发效率和代码复用。选择适合的模板引擎,利用其数据注入、模板继承等特性,保持模板简洁,注重安全性,是最佳实践。例如,Jinja2允许在HTML中嵌入变量并处理循环,简化渲染过程。
154 0
|
人工智能 自然语言处理
华为GTS LocMoE+:高可扩展性亲和度 MoE 架构,低开销实现主动路由
【8月更文挑战第6天】华为GTS提出LocMoE+,一种高可扩展性Mixture-of-Experts架构,通过亲和度路由策略高效分配任务,自适应调整专家容量优化资源利用,并采用通信优化技术减少开销,实现在保证性能的同时大幅提升训练效率和推理速度,尤其在多节点集群环境下优势明显。
200 1
|
安全 Java API
springboot 单点登录实现原理
【7月更文挑战第2天】单点登录(Single Sign-On,SSO)是一种用户认证方式,用户在多个应用系统中只需要登录一次,就可以访问所有相互信任的应用系统。
273 1