1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-12-16 15:44:39 +00:00
202401-programming-assignments/【实践课外】13.指针1/6-4 求一组数中的最大值、最小值和平均值.c

21 lines
316 B
C

float fun(int a[], int n, int *max, int *min) {
float sum = a[0];
*max = a[0];
*min = a[0];
for (int i = 1; i < n; i++) {
sum += a[i];
if (a[i] > *max) {
*max = a[i];
}
if (a[i] < *min) {
*min = a[i];
}
}
return sum / n;
}