求求大神们帮个忙修改一下我这个代码,万分感谢,拜托了
在跳水比赛中,给予每名潜水员的分数如下。每个法官给出一个分数,通过去掉最高分和最低分并计算其余的平均值来找到最终分数。写一个C程序,在竞赛中读入评委人数,然后为每名裁判输入一个成绩。进行必要的计算并显示最高分,最低分分数和最终分数。以下数据检查必须在程序中进行:
a)裁判人数必须在4人到8人之间
b)每个裁判可以给出一个从0.0到10.0的标记(一个可能包含分数的实数)
#include <stdio.h>
int main() {
int numOfJudges;
printf("Diving Competition\n\n");
printf("Enter Number of Judges (4 to 8): ");
scanf("%d", &numOfJudges);
printf("\n");
if(numOfJudges >= 4 && numOfJudges <= 8) {
float num[numOfJudges];
float max, min, final = 0.0;
min = num[0];
max = num[numOfJudges];
for(int i = 0; i < numOfJudges; i++) {
printf("Judge %d score: ", i+1);
scanf("%f", &num[i]);
if(num[i] >= 0.0 && num[i] <= 10.0) {
if(num[i] < min) {
min = num[i];
}
if(num[i] > max) {
max = num[i];
}
final += num[i];
} else {
printf("Judges can only award a mark from 0.0 to 10.0, exit and try again");
return 1;
}
}
final = final - min;
printf("\nMin: %.1f, Max: %.1f, Final Result: %.1f", min, max, final/(numOfJudges-1));
} else {
printf("Please exit and enter the correct number of judges between 4 to 8");
return 1;
}
}