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