c语言大作业——学生成绩管理系统v5.0

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

//成绩管理系统v1.0#includestdio.h#includestdlib.h#includestring.h#defineN30#defineM6typedefstructstudent{longstudentID;charstudentName[10];intscore[M];}STU;voidInput(STUstu[],intn,intm);voidTotalave(STUstu[],intn,intm);voidevestuTotalave(STUstu[],intn,intm);voidScoredes(STUstu[],intn,intm);voidScoreas(STUstu[],intn,intm);voidNumas(STUstu[],intn,intm);voidDicas(STUstu[],intn,intm);voidSearchbynum(STUstu[],intn,intx,intm);voidSearchbymane(STUstu[],intn,charname[],intm);voidstatistis(STUstu[],intn,intm);voidList(STUstu[],intn,intm);intmain(){intn,c,x,m;charname[10];STUstu[N];printf(输入学生人数);scanf(%d,&n);printf(输入考试科目);scanf(%d,&m);printf(1.Inputrecord\n);printf(2.Caculatetotelandaveragescoreofeverycourse\n);printf(3.Caculatetotelandaveragescoreofeverystudent\n);printf(4.Sortindescendingorderbytotalscoreofeverystudent\n);printf(5.Sortinascendingorderbytotalscoreofeverystudent\n);printf(6.Sortinascendingorderbynumber\n);printf(7.Sortinascendingorderbyname);printf(8.Searchbynumber\n);printf(9.Searchbyname\n);printf(10.Statisticanalysisforeverycourse\n);printf(11.Listrecord\n);printf(0.Exit\n);printf(Pleaseenteryourchoice:\n);printf(\n);for(;;){scanf(%d,&c);switch(c){case1://录入学生学号和各科成绩Input(stu,n,m);printf(Pleaseenteryourchoice:\n);break;case2://计算每门课程的总分和平均分Totalave(stu,n,m);printf(Pleaseenteryourchoice:\n);break;case3://计算每个学生的总分和平均分evestuTotalave(stu,n,m);break;case4://按每个学生的总分由高到低排出名次表Scoredes(stu,n,m);printf(Pleaseenteryourchoice:\n);break;case5://按每个学生的总分由低到高排出名次表Scoreas(stu,n,m);printf(Pleaseenteryourchoice:\n);break;case6://按学号由小到大排出名次表Numas(stu,n,m);printf(Pleaseenteryourchoice:\n);break;case7://按姓名的字典顺序排出成绩表Dicas(stu,n,m);printf(Pleaseenteryourchoice:\n);break;case8://按学号查询学生排名及其各科成绩printf(请输入查找学号\n);scanf(%d,&x);Searchbynum(stu,n,x,m);printf(Pleaseenteryourchoice:\n);break;case9://按姓名查询学生排名及其各科成绩printf(请输入查找姓名\n);scanf(%s,name);getchar();Searchbymane(stu,n,name,m);printf(Pleaseenteryourchoice:\n);break;case10://成绩分析所占百分比statistis(stu,n,m);printf(Pleaseenteryourchoice:\n);break;case11://全部输出List(stu,n,m);Totalave(stu,n,m);printf(Pleaseenteryourchoice:\n);break;case0:exit(0);}}return0;}voidInput(STUstu[],intn,intm)//1{inti,j;for(i=0;in;i++){printf(Inputstudent'sID,nameandscore);scanf(%ld,&stu[i].studentID);scanf(%s,stu[i].studentName);for(j=0;jm;j++)scanf(%d,&stu[i].score[j]);}}voidTotalave(STUstu[],intn,intm)//2.计算每门课程的总分和平均分{inti,j,sum[M];doubleave[M];for(j=0;jm;j++){sum[j]=0;for(i=0;in;i++){sum[j]=sum[j]+stu[i].score[j];}ave[j]=(double)sum[j]/n;}for(i=0;im;i++)printf(科目%d的总分=%d,课程的平均分=%f\n,i+1,sum[i],ave[i]);}voidevestuTotalave(STUstu[],intn,intm)//3.计算每个学生的总分和平均分{inti,j,sum[N];doubleave[N];for(i=0;in;i++){sum[i]=0;for(j=0;jm;j++){sum[i]=sum[i]+stu[i].score[j];}ave[i]=(double)sum[i]/m;}for(i=0;in;i++)printf(学号为%ld,姓名为%s的总分=%d,其平均分=%f\n,stu[i].studentID,stu[i].studentName,sum[i],ave[i]);}voidScoredes(STUstu[],intn,intm)//4.按每个学生的总分由高到低排出名次表{inti,j,k,h,sum[N];STUt;for(i=0;in;i++){sum[i]=0;for(j=0;jm;j++){sum[i]=sum[i]+stu[i].score[j];}}for(i=0;in;i++){k=i;for(j=i+1;jn;j++){if(sum[j]sum[k])k=j;}if(i!=k){t=stu[i],h=sum[i];stu[i]=stu[k],sum[i]=sum[k];stu[k]=t,sum[k]=h;}}for(i=0;in;i++)printf(ID:%10ld,name:%s,score:%d\n,stu[i].studentID,stu[i].studentName,sum[i]);//以长整形打印用%ld}voidScoreas(STUstu[],intn,intm)//5.按每个学生的总分由di到gao排出名次表{inti,j,k,h,sum[N];STUt;for(i=0;in;i++){sum[i]=0;for(j=0;jm;j++){sum[i]=sum[i]+stu[i].score[j];}}for(i=0;in;i++){k=i;for(j=i+1;jn;j++){if(sum[j]sum[k])k=j;}if(i!=k){t=stu[i],h=sum[i];stu[i]=stu[k],sum[i]=sum[k];stu[k]=t,sum[k]=h;}}for(i=0;in;i++)printf(ID:%10ld,name:%s,score:%d\n,stu[i].studentID,stu[i].studentName,sum[i]);//以长整形打印用%ld}voidNumas(STUstu[],intn,intm)//6.按学号由小到大排出名次表{inti,j,k;STUt;for(i=0;in;i++){k=i;for(j=i+1;jn;j++){if(stu[j].studentIDstu[k].studentID)k=j;}if(i!=k)t=stu[k],stu[k]=stu[i],stu[i]=t;}for(i=0;in;i++){printf(ID:%10ld,name:%s\n,stu[i].studentID,stu[i].studentName);//以长整形打印用%ldfor(j=0;jm;j++)printf(project%dscore:%d\n,j+1,stu[i].score[j]);}}voidDicas(STUstu[],intn,intm)//7.{inti,j;STUt;for(i=0;in;i++){for(j=i+1;jn;j++){if(strcmp(stu[i].studentName,stu[j].studentName)0)t=stu[i],stu[i]=stu[j],stu[j]=t;}}for(i=0;in;i++){printf(ID:%10ld,name:%s\n,stu[i].studentID,stu[i].studentName);for(j=0;jm;j++)printf(project:%d,score:%d\n,j+1,stu[i].score[j]);}}voidSearchbynum(STUstu[],intn,intx,intm)//8.按学号查询学生排名及其各科成绩{inti,j,c=1,find=0,sum[N];for(i=0;in;i++){sum[i]=0;for(j=0;jm;j++)sum[i]=sum[i]+stu[i].score[j];}for(i=0;in;i++){if(stu[i].studentID==x){find=1;break;}}if(find==0)printf(notfind\n);else{for(j=0;jn;j++){if(sum[j]sum[i])c++;}printf(ID:%10ldname:%s\n,stu[i].studentID,stu[i].studentName);//以长整形打印用%ldfor(j=0;jm;j++)printf(project%dscore:%d\n,j+1,stu[i].score[j]);printf(allscore:%d,order:%d\n,sum[i],c);}}voidSearchbymane(STUstu[],intn,charname[],intm)//9{inti,j,c=1,find=0,sum[N];for(i=0;in;i++){sum[i]=0;for(j=0;jm;j++)sum[i]=sum[i]+stu[i].score[j];}for(i=0;in;i++){if(strcmp(stu[i].studentName,name)==0){find=1;break;}}if(find==0

1 / 9
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功