题解 | #统计成绩#
统计成绩
https://www.nowcoder.com/practice/cad8d946adf64ab3b17a555d68dc0bba
#include <stdio.h> int main() { int a = 0; scanf("%d",&a); float arr[100]; for(int i = 0;i < a;i++) { scanf("%f",&arr[i]); } float max = arr[0]; float min = arr[0]; float sum = arr[0]; for(int i = 1;i < a;i++) { if(arr[i] > max) { max = arr[i]; } if(arr[i] < min) { min = arr[i]; } sum += arr[i]; } float ave = sum / a; printf("%.2f %.2f %.2f\n",max,min,ave); return 0; }