题解 | #统计成绩#
统计成绩
https://www.nowcoder.com/practice/cad8d946adf64ab3b17a555d68dc0bba
#include <stdio.h> int main() { float a[10]; float sum = 0, max = 0, min = 100.0; int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%f", &a[i]); sum += a[i]; if (a[i] > max) { max = a[i]; } if (a[i] < min) { min = a[i]; } } printf("%.2f %.2f %.2f", max, min, sum / n); return 0; }
数组存放成绩,输入的时候比较最大最小,然后在输出的时候计算平均值。