|
|
@ -269,7 +269,24 @@ SwapChar(stu[k].name, stu[i].name); //交换姓名
|
|
|
|
```
|
|
|
|
```
|
|
|
|
void SortbyName(STU stu[],int n,int m)
|
|
|
|
void SortbyName(STU stu[],int n,int m)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
int i, j, t;
|
|
|
|
|
|
|
|
for (i=0; i<n-1; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for (j = i+1; j<n; j++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (strcmp(stu[j].name, stu[i].name) < 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for (t=0; t<m; t++) //交换m门课程的成绩
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
SwapFloat(&stu[i].score[t], &stu[j].score[t]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
SwapFloat(&stu[i].sum, &stu[j].sum); //交换总分
|
|
|
|
|
|
|
|
SwapFloat(&stu[i].aver, &stu[j].aver); //交换平均分
|
|
|
|
|
|
|
|
SwapLong(&stu[i].num, &stu[j].num); //交换学号
|
|
|
|
|
|
|
|
SwapChar(stu[i].name, stu[j].name); //交换姓名
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|