‹ 上一题 下一题 ›

g2-03363. GESP-2级-2025-12-单选-第15题 未做

某学校举办“十佳歌手大奖赛”,经过选拔最终参赛选手有 人,评委 人,最终计分规则去掉一个最高分去掉一个最低分作为该参赛选手的最终得分,并输出该得分。如果单个评委可给满分为 分,则相关说法正确的是( )。

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);
}
  • A. 程序总体逻辑错误。因为要去掉最高分和最低分,需要排序,而程序没有相关代码。
  • B. 内层循环和外层循环之间的三行代码也就是 max_score = 0 开始的三行代码应该移动到外层循环外。
  • C. L1 和 L2 标记的两行代码可以分别改为简单的 if 语句或 ? : 语句。
  • D. total_score += now_score 不可以更改为 total_score = total_score + now_score。
未选择
输入
输出

            
答案