1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-12-16 15:44:39 +00:00
202401-programming-assignments/【实践课内】7.数组1/7-2 输出去掉最大值和最小值后剩下数据的和.c

32 lines
486 B
C

#include <stdio.h>
int a[10], max = -1e8, min = 1e8, sum;
int main() {
for (int i = 1; i <= 6; i++) {
scanf("%d", &a[i]);
}
for (int i = 1; i <= 6; i++) {
if (a[i] > max) {
max = a[i];
}
if (a[i] < min) {
min = a[i];
}
}
for (int i = 1; i <= 6; i++) {
if (a[i] == max || a[i] == min) {
continue;
}
sum += a[i];
}
printf("%d\n", sum);
return 0;
}