题解 | #公务员面试#
公务员面试
https://www.nowcoder.com/practice/f3a134908d5b41869f14f58307008a97
#include <stdio.h>
int main() {
int arr[7], sum = 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) {
getchar();
// Bubble Sort, from min to max
for (int i = 0; i < sizeof(arr) / sizeof(int) - 1; i++) {
for (int j = 0; j < sizeof(arr) / sizeof(int) - i - 1; j++) {
if (arr[j] > arr[j + 1]) {
int tmp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = tmp;
}
}
}
for (int k = 1; k < sizeof(arr) / sizeof(int) - 1; k++) {
sum += arr[k];
}
printf("%.2lf\n", sum / 5.0);
sum = 0;
}
return 0;
}