1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-12-16 15:44:39 +00:00
202401-programming-assignments/【实践课外】15.结构体1/6-2 按等级统计学生成绩.c

19 lines
395 B
C
Raw Normal View History

2024-12-11 03:41:51 +00:00
int set_grade(struct student *p, int n) {
int cnt = 0;
for (int i = 0; i < n; i++) {
if (p[i].score >= 85) {
p[i].grade = 'A';
} else if (p[i].score >= 70) {
p[i].grade = 'B';
} else if (p[i].score >= 60) {
p[i].grade = 'C';
} else {
p[i].grade = 'D';
cnt++;
}
}
return cnt;
}