|
|
|
@ -14,7 +14,6 @@ typedef struct {
|
|
|
|
|
Student students[MAX_STUDENTS];
|
|
|
|
|
int studentCount = 0;
|
|
|
|
|
|
|
|
|
|
// 函数声明
|
|
|
|
|
void inputAndSortStudents();
|
|
|
|
|
int compareStudents(const void *a, const void *b);
|
|
|
|
|
void queryStudents();
|
|
|
|
@ -39,7 +38,7 @@ void addStudent(int id, int class, char *name, float score1, float score2, float
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void inputAndSortStudents() {
|
|
|
|
|
// 这里应该有一个循环来输入学生信息
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addStudent(10001, 11, "Zhang", 99.5, 88.5, 89.5);
|
|
|
|
|
addStudent(10002, 12, "Yang", 77.9, 56.5, 87.5);
|
|
|
|
@ -49,7 +48,6 @@ void inputAndSortStudents() {
|
|
|
|
|
addStudent(10006, 12, "Mao", 22.1, 45.9, 99.2);
|
|
|
|
|
addStudent(10007, 13, "Zhan", 35.6, 67.9, 88.0);
|
|
|
|
|
|
|
|
|
|
// 排序学生信息
|
|
|
|
|
qsort(students, studentCount, sizeof(Student), compareStudents);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -59,7 +57,7 @@ int compareStudents(const void *a, const void *b) {
|
|
|
|
|
if (studentA->class != studentB->class) {
|
|
|
|
|
return studentA->class - studentB->class;
|
|
|
|
|
}
|
|
|
|
|
return (studentB->total - studentA->total); // 降序排列
|
|
|
|
|
return (studentB->total - studentA->total);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void queryStudents() {
|
|
|
|
|