一维数组实验题:大奖赛现场统分。已知某大奖赛有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;
    }
}
相关文章
|
5月前
|
存储 Kubernetes 调度
|
12月前
|
人工智能 数据安全/隐私保护
2025年3D 虚拟AI数字人公司厂商推荐排名:魔珐科技领跑行业
2025年,魔珐科技凭借全栈技术突破与场景化落地能力,在3D虚拟AI数字人领域脱颖而出,成为行业领军者。本文基于技术实力、市场表现、客户案例及行业影响力四大维度,解析魔珐科技为何位列2025年3D虚拟AI数字人公司厂商推荐榜首。
|
前端开发 JavaScript API
一文吃透 Promise 与 async/await,异步编程也能如此简单!建议收藏!
在前端开发中,异步编程至关重要。本文详解了同步与异步的区别,通过生活化例子帮助理解。深入讲解了 Promise 的概念、状态及链式调用,并引入 async/await 这一语法糖,使异步代码更清晰易读。还介绍了多个异步任务的组合处理方式,如 Promise.all 与 Promise.race。掌握这些内容,将大幅提升你的异步编程能力,写出更优雅、易维护的代码,助力开发与面试!
732 0
一文吃透 Promise 与 async/await,异步编程也能如此简单!建议收藏!
|
9月前
阿里云服务器买完了,在哪申请发票?有发票开具指南吗?还有抬头设置
阿里云购服务器后,登录用户中心→发票管理,可开电子/纸质发票。抬头以实名信息为准(个人或企业),支持普票、专票。首次需设置抬头,订单勾选后一键开具。税率通常6%(硬件13%),电子发票可报销。详情见官方指南。
662 2
|
9月前
|
网络协议 Java Unix
从 BIO 到 AIO 全链路拆解:Reactor 模型演进与高并发 IO 架构落地实战
本文深入解析Java高并发IO模型演进与Reactor架构,从BIO、NIO到AIO的技术发展路径。首先介绍UNIX五种IO模型标准,详细对比同步/异步、阻塞/非阻塞的核心差异。重点剖析NIO的三大组件(Channel、Buffer、Selector)实现原理,并通过完整代码示例展示BIO/NIO/AIO的服务端与客户端实现。系统讲解Reactor模型的三个阶段演进:单线程→单Reactor多线程→主从Reactor多线程,结合Netty框架展示工业级实现方案。最后提供线程模型优化、TCP参数调优等最佳实践
411 3
|
Unix Shell Windows
Windows PowerShell技巧:使用findstr实现类似grep的功能
显示带有线路编号**: `/N`选项将显示每条结果前面带有其在线路上出现位置编号。
1797 7
|
SQL Web App开发 数据可视化
2025年最热门的TOP5报表工具排行榜
很多数据项目中都会用报表工具来做报表,怎么选一款好用的工具一直是个难题,今天,我们一起盘点5款热门报表软件,看看每款报表工具的特点,看看哪款更适合您。
|
9月前
|
Ubuntu Linux iOS开发
给计算机新生的操作系统全景指南
资深开发工程师致大一新生的操作系统入门指南:从Windows的易用、macOS的优雅,到Linux的开源力量,详解三大系统核心特性与开发者价值,助你夯实基础、拓宽视野。