歌手比赛评分程序要求输入十个评委的分数保存到数组中 去掉最高分和最低分 计算歌手的平均分

歌手比赛评分程序要求输入十个评委的分数保存到数组中 去掉最高分和最低分 计算歌手的平均分


#include<stdio.h>
#include<stdlib.h>


int main(void)
{
 
    float score[10];
    float max = 0, min = 10000, total_score = 0;

    printf("输入十个分数 空格隔开:");
    for (int i = 0; i < 10; ++i){
        scanf("%f", &score[i]);
        //计算最高分
        if (max < score[i])
            max = score[i];
        //计算最低分
        if (min > score[i])
            min = score[i];
        //计算总分
        total_score += score[i];
    }

    //减去最高分
    total_score -= max;
    //减去最低分
    total_score -= min;
    printf("平均分:%f\n", total_score / 10);

    system("pause");
    return 0;
}