某学校举办“十佳歌手大奖赛”,经过选拔最终参赛选手有25人,评委10人,最终计分规则去掉一个最高分、去掉一个最低分作为该参赛选手的最终得分,并输出该得分。如果单个评委可给满分为10分,相关程序代码如下:
float total_score, max_score, min_score, now_score;
for (int i = 0; i < 25; i++) {
max_score = 0; // 记录最高分
min_score = 10; // 记录最低分
total_score = 0; // 记录总分
for (int j = 0; j < 10; j++) {
cin >> now_score; // 录入评委打分
max_score = max(max_score, now_score); // L1
min_score = min(min_score, now_score); // L2
total_score += now_score;
}
cout << (total_score - max_score - min_score);
}