题解 | #公务员面试#
公务员面试
https://www.nowcoder.com/practice/f3a134908d5b41869f14f58307008a97
#include <stdio.h> #define MAX(a,b) ({\ typeof(a) _a = (a);\ typeof(b) _b = (b);\ (void) (&_a == &_b);\ _a > _b ? _a: _b;\ }) #define MIN(a, b) ({\ typeof(a) _a = (a);\ typeof(b) _b = (b);\ (void) (&_a == &b);\ _a > _b ? _b : _a;\ }) int main() { int array[7] = {0}; while (scanf("%d %d %d %d %d %d %d", array, array+1, array+2, array+3, array+4, array+5, array+6) != EOF) { // 注意 while 处理多个 case // 64 位输出请用 printf("%lld") to int sum = 0, max = 0,min =array[0] ; float ave = 0.0; for (int i = 0; i < 7; i++) { sum += array[i]; max = MAX(max, array[i]); min = MIN(min, array[i]); } ave = (float)(sum - max - min) / 5; printf("%.2f\n", ave); } return 0; }