为什么这个总有错误,我看了半天,感觉在学生成绩管理系统里的排序的这个想法没错呀,可是就是有问题,帮帮忙,谢谢了!
#define N 100struct student
{ long int number;
char name[10];
float s[6],sum[2];
}stu[N]={{10010,"lin",1,1,1,1,1},
{10011,"huang",0,0,0,0,0},
{10012,"cheng",2,2,2,2,2}
};
void Sort()
{int i,j,k;
float m,a[2]={0},sum=0;
for (i=0;i<3;i++)
{sum+=stu[i].s[0]+stu[i].s[1]+stu[i].s[2]+stu[i].s[3]+stu[i].s[4];
a[i]=sum;
sum=0;}
for (i=0;i<3;i++)
printf("%f",a[i]);
for (i=0;i<3;i++)
{for (j=0;j<i+1;j++)
{ if (a[i]<a[j])
{ m=a[i];
a[i]=a[j];
a[j]=m;
stu[i].number=stu[j].number;
strcpy(stu[i].name,stu[j].name);
for (k=0;k<5;k++)
{stu[i].s[k]=stu[j].s[k]; }}}}
printf("||number||name ||score1||score2||score3||score4||score5|| sum ||\n");
for (j=0;j<3;j++)
{printf("||%ld ||%s ||%6.1f||%6.1f||%6.1f||%6.1f||%6.1f||%6.1f||\n",stu[j].number,stu[j].name,stu[j].s[0],stu[j].s[1],stu[j].s[2],stu[j].s[3],stu[j].s[4],sum+=stu[j].s[0]+stu[j].s[1]+stu[j].s[2]+stu[j].s[3]+stu[j].s[4]);
printf("\n");}
printf("please wait input any key continue");
getch();}