题解 | #公务员面试#
公务员面试
https://www.nowcoder.com/practice/f3a134908d5b41869f14f58307008a97
#include <stdio.h> int main() { int n = 0, max = 0, min = 100, sum = 0, score = 0; while (scanf("%d", &score) == 1)//每次读一个分数进来 { n++; //寻找最高分数 if (score > max) max = score; //寻找最低分数 if (score < min) min = score; //总分数和 sum += score; if (n == 7)//读到七个分数时 { printf("%.2lf\n", (sum - max - min) / 5.0);//总分减去最高分和最低分然后除以5.0求平均值(保留两个小数点) max = 0; min = 100; n = 0; sum = 0; } } return 0; }