This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
//4 函数功能:按选择法将数组sum的元素值排序
void SortbyScore(STU stu[],int n,int m,int (*compare)(float a,float b))
{
int i, j, k, t;
for (i=0; i<n-1; i++)
k = i;
for (j=i+1; j<n; j++)
if ((*compare)(stu[j].sum, stu[k].sum)) k = j;
}
if (k != i)
for (t=0; t<m; t++) // 交换m门课程的成绩
SwapFloat(&stu[k].score[t], &stu[i].score[t]);
SwapFloat(&stu[k].sum, &stu[i].sum); // 交换总分
SwapFloat(&stu[k].aver, &stu[i].aver); // 交换平均分
SwapLong(&stu[k].num, &stu[i].num); // 交换学号
SwapChar(stu[k].name, stu[i].name); // 交换姓名