歌星大赛中n个选手,10个评委打分,分数为1——10分。选手得分:去掉一个最高和最低分后剩余8个的平均分,

2025-02-26 22:05:53
推荐回答(2个)
回答1:

这个很简单的,我做过,只是分数是1-100分的,你改下就OK了。
#include
#include
int
main(void)
{
int score[10];
int i;
int max;
int min;
int m;
int n;
int best_score;
int worst_score;
float average;
int sum=0,left_sum;
float cha,smallest_cha,biggest_cha;
printf("Please input ten scores(0--100) :\n");
for(i=0;i<10;i++)
scanf("%d",&score[i]);
for(i=0;i<10;i++)
sum+=score[i];
max=score[0];
min=score[0];
for(i=1;i<10;i++)
{
if(score[i]>=max)
max=score[i];
else if(score[i]<=min)
min=score[i];
}
left_sum=sum-max-min;
average=(float)left_sum/8;
printf("The max score is %d\n",max);
printf("The min score is %d\n",min);
printf("The average score is:");
printf("%f\n",average);
best_score=score[0];
worst_score=score[0];
smallest_cha=score[0]-average;
biggest_cha=score[0]-average;

if(smallest_cha<=0)
{
smallest_cha=-smallest_cha;
biggest_cha=-biggest_cha;
}

for(i=1;i<10;i++)
{
cha=score[i]-average;
if(cha<=0)
cha=-cha;
if(cha<=smallest_cha)
{
best_score=score[i];
m=i+1;
smallest_cha=cha;
}
else if(cha>=biggest_cha)
{
worst_score=score[i];
n=i+1;
biggest_cha=cha;
}
}

printf("The best_score is %d,The best_judge is%d\n",best_score,m);
printf("The worst_score is %d,The worst_judge is%d\n",worst_score,n);
return 0;
}

回答2:

4分的最公平10分的最不公平