You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
System/mty4.md

693 B

// 函数功能按选择法将数组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); // 交换姓名 } } }