(1)比赛评分。从10个评委的评分中扣除一个最高分和一个最低分
时间: 2024-06-13 13:08:08 浏览: 164
以下是从10个评委的评分中扣除一个最高分和一个最低分的比赛评分的方法:
```c
#include <stdio.h>
float max(float b[]) {
float max = b[0];
for (int i = 1; i < 10; i++) {
if (b[i] > max) {
max = b[i];
}
}
return max;}
float min(float b[]) {
float min = b[0];
for (int i = 1; i < 10; i++) {
if (b[i] < min) {
min = b[i];
}
}
return min;
}
float sum(float b[]) {
float sum = 0;
for (int i = 0; i < 10; i++) {
sum += b[i];
}
return sum;}
int main() {
float score[10];
float max_score, min_score, total_score;
printf("请输入10个评委的评分:\n");
for (int i = 0; i < 10; i++) {
scanf("%f", &score[i]);
}
max_score = max(score);
min_score = min(score);
total_score = sum(score) - max_score - min_score;
printf("去掉一个最高分%.2f和一个最低分%.2f后,选手的得分为%.2f\n", max_score, min_score, total_score / 8);
return 0;
}
```
阅读全文