题解 | #公务员面试#
公务员面试
https://www.nowcoder.com/practice/f3a134908d5b41869f14f58307008a97
#include<stdio.h>
int main() {
int i, max = 0, min = 100, sum = 0, count = 0;
double avg = 0.0;
while (scanf("%d ", &i) != EOF) {
if (i > max) {
max = i;
}
if (i < min) {
min = i;
}
sum += i;
count++;
if (count == 7) {
avg = (sum - min - max) / 5.0;
printf("%.2lf\n", avg);
max = 0;
min = 100;
sum=0;
count=0;
}
}
}
int main() {
int i, max = 0, min = 100, sum = 0, count = 0;
double avg = 0.0;
while (scanf("%d ", &i) != EOF) {
if (i > max) {
max = i;
}
if (i < min) {
min = i;
}
sum += i;
count++;
if (count == 7) {
avg = (sum - min - max) / 5.0;
printf("%.2lf\n", avg);
max = 0;
min = 100;
sum=0;
count=0;
}
}
}