题解 | #公务员面试#
公务员面试
https://www.nowcoder.com/practice/f3a134908d5b41869f14f58307008a97
#include <stdio.h> int main() { //存储数据 int arr[7] = {0}; int i = 0; while (scanf("%d%d%d%d%d%d%d", &arr[0], &arr[1], &arr[2], &arr[3], &arr[4], &arr[5], &arr[6]) != EOF) { //找最大值 int max = arr[0]; for (i = 0; i < 7; i++) { if (arr[i] > max) { max = arr[i]; } } //找最小值 int min = arr[0]; for (i = 0; i < 7; i++) { if (arr[i] < min) { min = arr[i]; } } //求和 int sum = 0; for (i = 0; i < 7; i++) { sum = sum + arr[i]; } //求平均值 float ret = (sum - max - min) / 5.0; printf("%.2f\n", ret); } return 0; }