#includestdio.h#includestring.h#includestdlib.h#defineN30#defineMAX_LEN10#defineM3typedefstructstudent{longstudentID;charstudentName[10];intscore[3];}STUDENT;voidInputScore(STUDENTstu[],intn);voidSumforCorse(STUDENTstu[],intn,floatsumcorse[],floatavercorse[]);voidSumforStudent(STUDENTstu[],intn,floatsumstudent[],floataverstudent[]);voidDateScore(STUDENTstu[],intn,int(*compare)(inta,intb));voidDateNum(STUDENTstu[],intn);voidDateName(STUDENTstu[],intn);intLinSearch(STUDENTstu[],longx,intn);intLinSearchname(STUDENTstu[],charname[],intn);voidRateScore(STUDENTstu[],intn);voidPrintfScoreNum(STUDENTstu[],intn,floatsumcorse[],floatavercorse[]);voidPrintf(STUDENTstu[],intn);voidSwapnum(long*a,long*b);voidSwapsum(int*a,int*b);voidSwapscore(int*a,int*b);intAscending(inta,intb);intDescending(inta,intb);voidWritetoFile(STUDENTstu[],intn);intReadfromFILE(STUDENTstu[]);main(){intn,m,pos=0,i;longx=0;floatavercorse[3]={0},averstudent[N]={0},sumcorse[3]={0},sumstudent[N]={0};charname[MAX_LEN];STUDENTstu[N];printf(howmanystudent?);scanf(%d,&n);InputScore(stu,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);scanf(%d,&m);switch(m){case1:SumforCorse(stu,n,sumcorse,avercorse);break;case2:SumforStudent(stu,n,sumstudent,averstudent);break;case3:DateScore(stu,n,Descending);Printf(stu,n);break;case4:DateScore(stu,n,Ascending);Printf(stu,n);break;case5:DateNum(stu,n);Printf(stu,n);break;case6:DateName(stu,n);Printf(stu,n);break;case7:{intj;DateScore(stu,n,Descending);printf(inputthenumberyouwanttosearch:);scanf(%ld,&x);pos=LinSearch(stu,x,n);if(pos!=-1)printf(MT\tEN\tPH\t:\n);for(j=0;j3;j++){printf(%d\t,stu[pos].score[j]);}printf(第%d名\n,pos+1);break;}case8:{intj;DateScore(stu,n,Descending);printf(inputthenameyouwanttosearch:\n);scanf(%s,name);pos=LinSearchname(stu,name,n);if(pos!=-1)printf(MT\tEN\tPH\t:\n);for(j=0;j3;j++){printf(%d\t,stu[pos].score[j]);}}printf(第%d名\n,pos+1);break;case9:RateScore(stu,n);break;case10:PrintfScoreNum(stu,n,sumcorse,avercorse);break;case11:WritetoFile(stu,n);break;case12:i=ReadfromFILE(stu);Printf(stu,i);break;}}voidInputScore(STUDENTstu[],intn){inti,j,m=3;for(i=0;in;i++){printf(inputthe%dstudentIDnamescore(MTENPH):,i+1);scanf(%ld,&stu[i].studentID);scanf(%s,stu[i].studentName);for(j=0;jm;j++){scanf(%d,&stu[i].score[j]);}}}voidSumforCorse(STUDENTstu[],intn,floatsumcorse[],floatavercorse[]){inti,j;for(j=0;j3;j++){for(i=0;in;i++){sumcorse[j]=sumcorse[j]+stu[i].score[j];}avercorse[j]=sumcorse[j]/n;switch(j){case0:printf(theMTtotleMT:%f\n,sumcorse[j]);printf(theMTaverMT:%f\n,avercorse[j]);break;case1:printf(theENtotleEN:%f\n,sumcorse[j]);printf(theENaverEN:%f\n,avercorse[j]);break;case2:printf(thePHtotlePH:%f\n,sumcorse[j]);printf(thePHaverPH:%f\n,avercorse[j]);break;}}}voidSumforStudent(STUDENTstu[],intn,floatsumstudent[],floataverstudent[]){inti,j;for(i=0;in;i++){for(j=0;j3;j++){sumstudent[i]=sumstudent[i]+stu[i].score[j];}averstudent[i]=sumstudent[i]/3;printf(第%d个thetotlescoreandaverageis%f%f\n,i+1,sumstudent[i],averstudent[i]);}}voidDateScore(STUDENTstu[],intn,int(*compare)(inta,intb)){inti,j,k,m,t,sumstudent[N];chartemp[MAX_LEN];for(i=0;in;i++){for(j=0;j3;j++){sumstudent[i]=sumstudent[i]+stu[i].score[j];}}for(t=0;tn-1;t++){k=t;for(m=t+1;mn;m++){if((*compare)(sumstudent[k],sumstudent[m])){k=m;}if(k!=t){Swapsum(&sumstudent[t],&sumstudent[k]);Swapnum(&stu[t].studentID,&stu[k].studentID);Swapscore(stu[t].score,stu[k].score);strcpy(temp,stu[t].studentName);strcpy(stu[t].studentName,stu[k].studentName);strcpy(stu[k].studentName,temp);}}}}voidSwapsum(int*a,int*b){inttemp;temp=*a;*a=*b;*b=temp;}voidSwapnum(long*a,long*b){longtemp;temp=*a;*a=*b;*b=temp;}voidSwapscore(int*a,int*b){inttemp[M],i;for(i=0;i3;i++){temp[i]=a[i];a[i]=b[i];b[i]=temp[i];}}intAscending(inta,intb){returnab;}intDescending(inta,intb){returnab;}voidDateNum(STUDENTstu[],intn){inti,j,k;chartemp[MAX_LEN];for(i=0;in-1;i++){k=i;for(j=i+1;jn;j++){if(stu[j].studentIDstu[k].studentID){k=j;}if(k!=i){Swapnum(&stu[i].studentID,&stu[k].studentID);Swapscore(stu[k].score,stu[i].score);strcpy(temp,stu[i].studentName);strcpy(stu[i].studentName,stu[k].studentName);strcpy(stu[k].studentName,temp);}}}}voidDateName(STUDENTstu[],intn){inti,j,k;chartemp[MAX_LEN];for(i=0;in;i++){k=i;for(j=i+1;jn;j++){if(strcmp(stu[k].studentName,stu[j].studentName)0){Swapnum(&stu[i].studentID,&stu[k].studentID);Swapscore(stu[i].score,stu[k].score);strcpy(temp,stu[i].studentName);strcpy(stu[i].studentName,stu[k].studentName);strcpy(stu[k].studentName,temp);}}}}intLinSearch(STUDENTstu[],longx,intn){inti;for(i=0;in;i++){if(stu[i].studentID==x)returni;}return-1;}intLinSearchname(STUDENTstu[],charname[],intn){inti;for(i=0;in;i++){if(strcmp(name,stu[i].studentName)==0)returni