t_name[i]);?fprintf(fp,"\n");?for(i=0;i<N;i++) /*写入学生数据、成绩信息*/?{ fprintf(fp,"%5s%5d",stud[i].name,stud[i].num); for(j=0;j<M;j++) { fprintf(fp,"%6.1f",stud[i].score[j]); } fprintf(fp,"\n");?}?if(fclose(fp)) /*文件关闭*/?{ printf("Cannotclosethefile!\n"); return;?}?printf("eed!\n");?getchar();?return;}voidrank() /*成绩排序*/{?voidswap(int*px,int*py);?int*a;?a=newint[N];?inti,j;?doubletot;?system("cls");?for(i=0;i<N;i++)/*循环计算总分*/?{ a[i]=i; for(j=0,tot=0;j<M;j++) tot=tot+stud[i].score[j];?stud[i].sum=tot;?}?for(i=0;i<N;i++){ for(j=0;j<N-i-1;j++) if(stud[a[j]].sum<stud[a[j+1]].sum) swap(&a[j],&a[j+1]);?}?printf("学号姓名总分\n");?for(i=0;i<N;i++) printf("%d\t%s\t%.1f\n",stud[a[i]].num,stud[a[i]].name,stud[a[i]].sum);?delete[]a;?printf("!输入任意键退出!\n");?getchar();}voidswap(int*px,int*py){?intt;?t=*px;?*px=*py;