1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-12-16 15:44:39 +00:00
202401-programming-assignments/【实践课内】16.结构体2/7-2 计算平均成绩.c

33 lines
499 B
C

#include <stdio.h>
struct student {
char id[10], name[10];
int score;
};
int n;
double avg;
struct student stu[10];
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%s %s %d", stu[i].id, stu[i].name, &stu[i].score);
avg += stu[i].score;
}
avg /= n;
printf("%.2lf\n", avg);
for (int i = 0; i < n; i++) {
if (stu[i].score < avg) {
printf("%s %s\n", stu[i].name, stu[i].id);
}
}
return 0;
}