我的
代码
#include<stdio.h>
#include<stdlib.h>
void grade( int list[], int n){
float max = list[0], min = list[0], average = 0;
for(int i = 0; i < n; ++i){
if(list[i] < min)
min = list[i];
if(list[i] > max)
max = list[i];
average += list[i];
}
printf("average = %.2f\nmax = %.2f\nmin = %.2f",average / n, max, min);
}
int main(){
int n, x, *list;
scanf("%d", &n);
list = (int*)malloc(sizeof(int) * n);
for(int i = 0; i < n; ++i){
scanf("%d", &list[i]);
}
grade(list, n);
return 0;
}