学生成绩管理系统v3.0

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

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

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

资源描述

//成绩管理系统v3.0//能动1302王清栋1306030217#includestdio.h#includestdlib.h#includestring.h#defineN30voidInput(longnum[],intscore[],intn,charname[][10]);voidTotalave(intscore[],intn);voidScoredes(longnum[],intscore[],intn,charname[][10]);voidScoreas(longnum[],intscore[],intn,charname[][10]);voidNumas(longnum[],intscore[],intn,charname[][10]);voidNameorder(longnum[],intscore[],intn,charname[][10]);voidSearchbyno(longnum[],intscore[],intn,intx,charname[][10]);voidSearchbyname(longnum[],intscore[],intn,charc[],charname[][10]);voidstatistis(intscore[],intn);voidList(longnum[],intscore[],intn,charname[][10]);intmain(){intn,score[N],c,x;longnum[N];charname[N][10];chary[10];printf(输入学生人数);scanf(%d,&n);//getchar();printf(1.Inputrecord\n);printf(2.Caculatetotelandaveragescoreofeverycourse\n);printf(3.Sortindescendingorderbyscore\n);printf(4.Sortinascendingorderbyscore\n);printf(5.Sortinascendingorderbynumber\n);printf(6.Sortindictionaryorderbyname\n);printf(7.Searchbynumber\n);printf(8.searchbyname\n);printf(9.Statisticanalysis\n);printf(10.Listrecord\n);printf(0.Exit\n);printf(Pleaseenteryourchoice:\n);printf(\n);for(;;){scanf(%d,&c);switch(c){case1://录入学生学号和各科成绩Input(num,score,n,name);printf(Pleaseenteryourchoice:\n);break;case2://计算每门课程的总分和平均分Totalave(score,n);printf(Pleaseenteryourchoice:\n);break;case3://按chengji由高到低排出名次表Scoredes(num,score,n,name);printf(Pleaseenteryourchoice:\n);break;case4://按chengji由低到高排出名次表Scoreas(num,score,n,name);printf(Pleaseenteryourchoice:\n);break;case5://按学号由小到大排出名次表Numas(num,score,n,name);printf(Pleaseenteryourchoice:\n);break;case6://按学号由小到大排出名次表Nameorder(num,score,n,name);printf(Pleaseenteryourchoice:\n);break;case7://按学号查询学生排名及其各科成绩printf(请输入查找学号\n);scanf(%d,&x);Searchbyno(num,score,n,x,name);printf(Pleaseenteryourchoice:\n);break;case8://按姓名查询学生排名及其各科成绩printf(请输入查找姓名\n);getchar();gets(y);Searchbyname(num,score,n,y,name);break;printf(Pleaseenteryourchoice:\n);case9://成绩分析所占百分比statistis(score,n);printf(Pleaseenteryourchoice:\n);break;case10://全部输出List(num,score,n,name);printf(Pleaseenteryourchoice:\n);break;case0:exit(0);}}return0;}voidInput(longnum[],intscore[],intn,charname[][10])//1{inti;for(i=0;in;i++){printf(Inputstudent'sID,nameandscore);scanf(%ld,&num[i]);scanf(%s,name[i]);scanf(%d,&score[i]);//getchar();}}voidTotalave(intscore[],intn)//2.计算课程的总分和平均分{inti,sum=0;doubleave;for(i=0;in;i++){sum=sum+score[i];}ave=(double)sum/n;printf(总分=%d,课程的平均分=%f\n,sum,ave);}voidScoredes(longnum[],intscore[],intn,charname[][10])//3.按学生的分由高到低排出名次表{inti,j,k,t,h;chartemp[10];for(i=0;in;i++){k=i;for(j=i+1;jn;j++){if(score[j]score[k])k=j;}if(i!=k){t=score[k],h=num[k],strcpy(temp,name[k]);score[k]=score[i],num[k]=num[i],strcpy(name[k],name[i]);score[i]=t,num[i]=h,strcpy(name[i],temp);}}for(i=0;in;i++)printf(ID:%10ld,name:%s,score:%d\n,num[i],name[i],score[i]);//以长整形打印用%ld}voidScoreas(longnum[],intscore[],intn,charname[][10])//4.按学生的分由高到低排出名次表{inti,k,t,h,j;chartemp[10];for(i=0;in;i++){k=i;for(j=i+1;jn;j++){if(score[j]score[k])k=j;}if(i!=k){t=score[k],h=num[k],strcpy(temp,name[k]);score[k]=score[i],num[k]=num[i],strcpy(name[k],name[i]);score[i]=t,num[i]=h,strcpy(name[i],temp);}}for(i=0;in;i++)printf(ID:%10ld,name:%s,score:%d\n,num[i],name[i],score[i]);//以长整形打印用%ld}voidNumas(longnum[],intscore[],intn,charname[][10])//5.按学号由小到大排出名次表{inti,k,h,t,j;chartemp[10];for(i=0;in;i++){k=i;for(j=i+1;jn;j++){if(num[j]num[k])k=j;}if(i!=k){t=score[k],h=num[k],strcpy(temp,name[k]);score[k]=score[i],num[k]=num[i],strcpy(name[k],name[i]);score[i]=t,num[i]=h,strcpy(name[i],temp);}}for(i=0;in;i++){printf(ID:%10ld,name:%s,score:%d\n,num[i],name[i],score[i]);//以长整形打印用%ld}}voidNameorder(longnum[],intscore[],intn,charname[][10])//6。按姓名的字典顺序排出成绩表{inti,k,t,h;chartemp[10];for(i=0;in;i++){for(k=i+1;kn;k++){if(strcmp(name[i],name[k])0){t=score[k],h=num[k],strcpy(temp,name[k]);score[k]=score[i],num[k]=num[i],strcpy(name[k],name[i]);score[i]=t,num[i]=h,strcpy(name[i],temp);}}}for(i=0;in;i++){printf(ID:%10ld,name:%s,score:%d\n,num[i],name[i],score[i]);//以长整形打印用%ld}}voidSearchbyno(longnum[],intscore[],intn,intx,charname[][10])//7.按学号查询学生排名及考试成绩{inthigh=n-1,low=0,mid,c=1,pos,find=0,i,k,h,j,t;chartemp[10];for(i=0;in;i++){k=i;for(j=i+1;jn;j++){if(num[j]num[k])k=j;}if(i!=k){t=score[k],h=num[k],strcpy(temp,name[k]);score[k]=score[i],num[k]=num[i],strcpy(name[k],name[i]);score[i]=t,num[i]=h,strcpy(name[i],temp);}}while(find==0&&low=high){mid=(high+low)/2;if(xnum[mid])low=mid+1;elseif(xnum[mid])high=mid-1;else{pos=mid;find=1;}}if(find==0)printf(notfind\n);else{for(i=0;in;i++){if(score[i]score[pos])c++;}printf(ID:%10ld,name:%s,order:%d,,num[pos],name[pos],c);//以长整形打印用%ldprintf(score:%d\n,score[pos]);}}voidSearchbyname(longnum[],intscore[],intn,charc[],charname[][10])//8。按姓名查询学生排名及其考试成绩{inti,pos=-1,d=1;for(i=0;in;i++){if(strcmp(name[i],c)==0)pos=i;}if(pos==-1)printf(notfind\n);else{for(i=0;in;i++){if(score[i]score[pos])d++;}}printf(ID:%10ld,name:%s,order:%d,,num[pos],name[pos],d);//以长整形打印用%ldprintf(score:%d\n,score[pos]

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

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

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

×
保存成功