#includestdio.h#includestdlib.h#includestring.h#definem_l10#definem_num30#definem_cs6typedefstructstudent{longnum;charname[m_l];floatscore[m_cs];floatsum;floataver;}STU;intmenu(void);voidReadscore(STUstu[],intn,intm);voidAversumofeverystudent(STUstu[],intn,intm);voidAversumofeverycourse(STUstu[],intn,intm);voidSortbyscore(STUstu[],intn,intm,int(*compare)(floata,floatb));intAscending(floata,floatb);intDescending(floata,floatb);voidswapfloat(float*x,float*y);voidswaplong(long*x,long*y);voidswapchar(charx[],chary[]);voidAssortbynum(STUstu[],intn,intm);voidSortbyname(STUstu[],intn,intm);voidSearchbynum(STUstu[],intn,intm);voidSearchbyname(STUstu[],intn,intm);voidStatisticAnlysis(STUstu[],intn,intm);voidPrintscore(STUstu[],intn,intm);voidWritetofile(STUstu[],intn,intm);voidReadfromfile(STUstu[],int*n,int*m);intmain(){charch;intn=0,m=0;STUstu[m_num];printf(请输入学生人数(n=%d):\n,m_num);scanf(%d,&n);printf(请输入课程数目(m=%d):\n,m_cs);scanf(%d,&m);while(1){ch=menu();switch(ch){case1:Readscore(stu,n,m);break;case2:Aversumofeverystudent(stu,n,m);break;case3:Aversumofeverycourse(stu,n,m);break;case4:Sortbyscore(stu,n,m,Descending);printf(\n成绩降序排序\n);Printscore(stu,n,m);break;case5:Sortbyscore(stu,n,m,Ascending);printf(\n成绩升序排序\n);Printscore(stu,n,m);break;case6:Assortbynum(stu,n,m);printf(\n学号升序排序\n);Printscore(stu,n,m);break;case7:Sortbyname(stu,n,m);printf(\n姓名字典升序排序\n);Printscore(stu,n,m);break;case8:Searchbynum(stu,n,m);break;case9:Searchbyname(stu,n,m);break;case10:StatisticAnlysis(stu,n,m);break;case11:Printscore(stu,n,m);break;case12:Writetofile(stu,n,m);break;case13:Readfromfile(stu,&n,&m);break;case0:printf(\n欢迎下次继续使用);exit(0);default:printf(\n输入错误);}}return0;}intmenu(void){intitems;printf(欢迎使用学生成绩管理系统\n);printf(1.输入成绩\n);printf(2.计算各个学生总成绩和平均成绩\n);printf(3.计算各门学科总成绩和平均成绩\n);printf(4.成绩降序排序\n);printf(5.成绩升序排序\n);printf(6.学号升序排序\n);printf(7.姓名升序排序\n);printf(8.通过学号查找成绩\n);printf(9.通过姓名查找成绩\n);printf(10.标准分析\n);printf(11.显示成绩\n);printf(12.写入文件\n);printf(13.读取文件\n);printf(0.退出\n);printf(请做出您的选择\n);scanf(%d,&items);returnitems;}voidReadscore(STUstu[],intn,intm){inti,j;printf(请输入学生学号,姓名,成绩\n);for(i=0;in;i++){scanf(%ld%s,&stu[i].num,stu[i].name);stu[i].sum=0;for(j=0;jm;j++){scanf(%f,&stu[i].score[j]);stu[i].sum+=stu[i].score[j];}if(m0)stu[i].aver=m0?stu[i].sum/m:-1;}}voidAversumofeverystudent(STUstu[],intn,intm){inti,j;for(i=0;in;i++){printf(学生%d:总成绩:%.1f,平均成绩:%.1f\n,i+1,stu[i].sum,stu[i].aver);}}voidAversumofeverycourse(STUstu[],intn,intm){inti,j;floatsum[m_cs],aver[m_cs];for(i=0;im;i++){sum[i]=0;for(j=0;jn;j++){sum[i]+=stu[j].score[i];}aver[i]=n0?sum[i]/n:-1;printf(课程%d:总成绩:%.1f,平均成绩:%.1f\n,i+1,sum[i],aver[i]);}}voidSortbyscore(STUstu[],intn,intm,int(*compare)(floata,floatb)){inti,j,k,t;for(i=0;in-1;i++){k=i;for(j=i+1;jn;j++){if((*compare)(stu[j].sum,stu[k].sum))k=j;}if(k!=i){for(t=0;tm;t++){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);}}}intAscending(floata,floatb){returnab;}intDescending(floata,floatb){returnab;}voidswapfloat(float*x,float*y){floatb;b=*x;*x=*y;*y=b;}voidswaplong(long*x,long*y){longb;b=*x;*x=*y;*y=b;}voidswapchar(charx[],chary[]){charb[m_l];strcpy(b,x);strcpy(x,y);strcpy(y,b);}voidAssortbynum(STUstu[],intn,intm){inti,j,k,t;for(i=0;in-1;i++){k=i;for(j=i+1;jn;j++){if(stu[j].numstu[k].num)k=j;}if(k!=i){for(t=0;tm;t++){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);}}}voidSortbyname(STUstu[],intn,intm){inti,j,t;for(i=0;in-1;i++){for(j=i+1;jn;j++){if(strcmp(stu[j].name,stu[i].name)0){for(t=0;tm;t++){swapfloat(&stu[i].score[t],&stu[j].score[t]);}swapfloat(&stu[j].sum,&stu[i].sum);swapfloat(&stu[j].aver,&stu[i].aver);swaplong(&stu[j].num,&stu[i].num);swapchar(stu[j].name,stu[i].name);}}}}voidSearchbynum(STUstu[],intn,intm){longnum;inti,j;printf(输入你所想要查找的学号\n);scanf(%ld,&num);for(i=0;in;i++){if(stu[i].num==num){printf(%ld\t%s\t,stu[i].num,stu[i].name);for(j=0;jm;j++){printf(%.0f\t,stu[i].score[j]);}printf(%.0f\t%.0f\n,stu[i].sum,stu[i].aver);return;}}printf(\n查无此号\n);}voidSearchbyname(STUstu[],intn,intm){charname[m_l];inti,j;printf(输入你所想要查找的姓名\n);scanf(%s,name);for(i=0;in;i++){if(strcmp(stu[i].name,name)==0){printf(%ld\t%s\t,stu[i].num,stu[i].name);for(j=0;jm;j++){printf(%.0f\t,stu[i].score[j]);}printf(%.0f\t%.0f\n,stu[i].sum,stu[i].aver);return;}}printf(\n查无此人\n);}voidStatisticAnlysis(STUstu[],intn,intm){inti,j,total,t[6];for(j=0;jm;j++){printf(学科:%d:\n,j+1);memset(t,0,sizeof(t));for(i=0;in;i++){if(stu[i].score[j]=0&&stu[i].score[j]60)t[0]++;elseif(stu[i].score[j]70)t[1]++;elseif(stu[i].score[j]80)t[2]++;elseif(stu[i].score[j]90)t[3]++;elseif(stu[i].score[j]100)t[4]++;elseif(stu[i].score[j]==100)t[5]++;}total=0;for(i=0;i=5;i++){total+=t[i];}for(i=0;i=5;i++){if(i==0)printf(60\t%d\t%.2f%%\n,t[i],(f