![](https://img2018.cnblogs.com/common/1315374/201912/1315374-20191220162519700-998857549.png)
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 int main(void)
5 {
6 int n;
7 double *p;
8 scanf("%d", &n);
9
10 p = (double *)calloc(n, sizeof(double));
11 for (int i = 0; i < n; i++)
12 {
13 scanf("%lf", p + i);
14 }
15
16 double sum = 0;
17 int max_index = 0;
18 int min_index = 0;
19
20 for (int i = 0; i < n; i++)
21 {
22 sum = sum + p[i];
23 if (p[i] > p[max_index])
24 {
25 max_index = i;
26 }
27 if (p[i] < p[min_index])
28 {
29 min_index = i;
30 }
31 }
32
33 printf("average = %.2f\n", sum / n);
34 printf("max = %.2f\n", p[max_index]);
35 printf("min = %.2f\n", p[min_index]);
36
37 free(p);
38 return 0;
39 }