只要输入10个评委的对某选手的评分结果,就可以根据上述规则自动计算出该选手的最终得分,c语言
时间: 2024-02-13 07:59:45 浏览: 27
好的,下面是 C 语言的代码,实现对一个选手的评分计算:
```c
#include <stdio.h>
int main() {
int score[10]; // 存储10个评委的评分
int sum = 0; // 存储总分数
int max_score = 0; // 存储最高分
int min_score = 10; // 存储最低分
// 输入10个评委的评分
printf("请输入10个评委的评分(0~10之间的整数):\n");
for (int i = 0; i < 10; ++i) {
scanf("%d", &score[i]);
sum += score[i];
if (score[i] > max_score) {
max_score = score[i];
}
if (score[i] < min_score) {
min_score = score[i];
}
}
// 计算最终得分
int final_score = (sum - max_score - min_score) / 8;
printf("最终得分为:%d\n", final_score);
return 0;
}
```
示例输出:
```
请输入10个评委的评分(0~10之间的整数):
8 9 7 6 10 9 8 7 7 8
最终得分为:7
```
以上代码实现了对一个选手的评分计算,需要注意的是,此代码中假设输入的评分都是合法的,即在 0~10 之间的整数。如果有非法评分需要进行异常处理。