void SortByTotalScore()
{
int i,j;
struct Student temp;
for(i = 0; i < N; i++)
{
if(strcmp((ptr+i)->stuID,"")!=0)/*保证只输出有效数据*/
stu[i].totalScore= ((ptr+i)->chineseScore) + ((ptr+i)->mathScore) + ((ptr+i)->englishScore);
}
for(i = 0;i < N; i++)
{
if( strcmp((ptr+i)->stuID,"") != 0 )
{
for(j = 0; j< N-i-1; j++ )
{
if(stu[j].totalScore < stu[j+1].totalScore)
{
temp=stu[j];
stu[j]=stu[j+1];
stu[j+1]=temp;
}
}
}
}
printf("学生信息如下:\n");
printf("学号\t姓名\t语文成绩\t数学成绩\t英语成绩\t总成绩\n");
for(i = 0; i < N; i++)
{
if(strcmp((ptr+i)->stuID,"")!=0)/*保证只输出有效数据*/
printf("%s\t%s\t%5.2d\t%10.2d\t%10.2d\t%10.2d\n",(ptr+i)->stuID,(ptr+i)->stuName,(ptr+i)->chineseScore,(ptr+i)->mathScore,(ptr+i)->englishScore,(ptr+i)->totalScore);
}
fflush(stdin);
system("pause");
}