题解 | #公务员面试#
公务员面试
https://www.nowcoder.com/practice/f3a134908d5b41869f14f58307008a97
#include <stdio.h> // int main() { int max = 0;//最大值 int min = 100;//最小值 int count = 0;//计数器 int score = 0;//裁判打的分数 int sum = 0;//成绩之和 while(scanf("%d", &score) != EOF) { //找最大值和最小值,并相加成绩 if(score > max) { max = score; } if(score < min) { min = score; } sum += score; count++; //如果满7个成绩,输出并重置计数器和偏移量 if(count == 7) { //去掉最大值和最小值并输出成绩 printf("%.2f\n", (sum-max-min)/5.0); //重置 count = 0; max = 0; min = 100; sum = 0; } } return 0; }