mirror of
https://github.com/renbaoshuo/202401-programming-assignments.git
synced 2024-12-16 15:44:39 +00:00
21 lines
316 B
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;
|
|
}
|