1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-12-16 15:44:39 +00:00
202401-programming-assignments/【实践课内】4.循环结构1/7-3 统计学生平均成绩与及格人数.c

28 lines
483 B
C

#include <stdio.h>
int main() {
int n, count = 0, sum_score = 0;
scanf("%d", &n);
if (n == 0) {
printf("average = 0.0\ncount = 0\n");
} else {
for (int i = 1; i <= n; i++) {
int score;
scanf("%d", &score);
sum_score += score;
if (score >= 60) {
count++;
}
}
printf("average = %.1lf\ncount = %d\n", (double)sum_score / n, count);
}
return 0;
}