您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 项目/工程管理 > 学生成绩管理系统v4.0
//³É¼¨¹ÜÀíϵͳv4.01651618242//Äܶ¯1302ÍõÇ嶰1306030217#includestdio.h#includestdlib.h#includestring.h#defineMAX_LEN10/*×Ö·û´®×î´ó³¤¶È*/#defineSTU_NUM30/*×î¶àµÄѧÉúÈËÊý*/#defineCOURSE_NUM6/*×î¶àµÄ¿¼ÊÔ¿ÆÄ¿Êý*/intMenu(void);voidReadScore(longnum[],charname[][MAX_LEN],floatscore[][COURSE_NUM],intn,intm);voidAverSumofEveryStudent(floatscore[][COURSE_NUM],intn,intm,floatsum[STU_NUM],floataver[STU_NUM]);voidAverSumofEveryCourse(floatscore[][COURSE_NUM],intn,intm);voidSortbyScore(longnum[],charname[][MAX_LEN],floatscore[][COURSE_NUM],floatsum[],floataver[],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(longnum[],charname[][MAX_LEN],floatscore[][COURSE_NUM],floatsum[],floataver[],intn,intm);voidSortbyName(longnum[],charname[][MAX_LEN],floatscore[][COURSE_NUM],floatsum[],floataver[],intn,intm);voidSearchbyNum(longnum[],charname[][MAX_LEN],floatscore[][COURSE_NUM],floatsum[],floataver[],intn,intm);voidSearchbyName(longnum[],charname[][MAX_LEN],floatscore[][COURSE_NUM],floatsum[],floataver[],intn,intm);voidStatisticAnalysis(floatscore[][COURSE_NUM],intn,intm);voidPrintScore(longnum[],charname[][MAX_LEN],floatscore[][COURSE_NUM],floatsum[],floataver[],intn,intm);intmain(){intn,c,m;float*score=NULL,*sum=NULL,*aver=NULL;long*num;char*name;while(n=0||n=30){printf(Inputstudentnumber(n%d):\n,STU_NUM);scanf(%d,&n);}num=(long*)malloc(n*sizeof(long));if(num==NULL){gotoend;}sum=(float*)malloc((n*sizeof(float)));if(sum==NULL){gotoend;}aver=(float*)malloc(n*sizeof(float));if(aver==NULL){gotoend;}name=(char*)malloc(n*sizeof(char)*MAX_LEN);if(name==NULL){gotoend;}//getchar();while(1){c=Menu();switch(c){case1:m=0;//¼ÈëѧÉúѧºÅºÍ¸÷¿Æ³É¼¨printf(Inputcoursenumber(m=%d):\n,COURSE_NUM);while(m=0||mCOURSE_NUM){scanf(%d,&m);}if(score!=NULL){free(score);score=NULL;}score=(float*)malloc(n*m*sizeof(float));ReadScore(num,name,score,n,m);break;case2://2.CaculatetotalandaveragescoreofeverycourseAverSumofEveryCourse(score,n,m);break;case3://3.CaculatetotalandaveragescoreofeverystudentAverSumofEveryStudent(score,n,m,sum,aver);break;case4://4.SortindescendingorderbyscoreSortbyScore(num,name,score,sum,aver,n,m,&Descending);break;case5://5.SortinascendingorderbyscoreSortbyScore(num,name,score,sum,aver,n,m,&Ascending);//SortbyScore(num,name,score,sumaver,n,m,(*compare));break;case6://6.SortinascendingorderbynumberAsSortbyNum(num,name,score,sum,aver,n,m);break;case7://7.SortindictionaryorderbynameSortbyName(num,name,score,sum,aver,n,m);break;case8://8.SearchbynumberSearchbyNum(num,name,score,sum,aver,n,m);break;case9://9.SearchbynameSearchbyName(num,name,score,sum,aver,n,m);break;case10://10.StatisticanalysisStatisticAnalysis(score,n,m);break;case11://ListrecordPrintScore(num,name,score,sum,aver,n,m);break;case0:printf(Endofprogram!);gotoend;default:printf(Inputerror!\n);break;}}end:if(num!=NULL){free(num);num=NULL;}if(sum!=NULL){free(sum);sum=NULL;}if(aver!=NULL){free(aver);aver=NULL;}if(name!=NULL){free(name);name=NULL;}return0;}intMenu(){intc=-1;printf(ManagementforStudents'scores\n);printf(1.Inputrecord\n);printf(2.Caculatetotalandaveragescoreofeverycourse\n);printf(3.Caculatetotalandaveragescoreofeverystudent\n);printf(4.Sortindescendingorderbyscore\n);printf(5.Sortinascendingorderbyscore\n);printf(6.Sortinascendingorderbynumber\n);printf(7.Sortindictionaryorderbyname\n);printf(8.Searchbynumber\n);printf(9.Searchbyname\n);printf(10.Statisticanalysis\n);printf(11.Listrecord\n);printf(0.Exit\n);printf(\n);while(c0||c11){printf(PleaseInputyourchoice:\n);scanf(%d,&c);}returnc;}voidReadScore(longnum[],charname[][MAX_LEN],floatscore[][COURSE_NUM],intn,intm){inti,j;printf(Inputstudent'sID,nameandscore:\n);for(i=0;in;i++){scanf(%ld,num+i);scanf(%9s,name[i]);for(j=0;jm;j++){scanf(%f,score[0]+i*m+j);}}}voidAverSumofEveryStudent(floatscore[][COURSE_NUM],intn,intm,floatsum[STU_NUM],floataver[STU_NUM]){inti,j;if(score[0]==NULL){printf(Pleasepress1inputdata.\n);return;}for(i=0;in;i++){sum[i]=0;for(j=0;jm;j++){sum[i]+=*(score[0]+i*m+j);}aver[i]=sum[i]/m;printf(student%d:sum=%.0f,aver=%.0f\n,i+1,sum[i],aver[i]);}}voidAverSumofEveryCourse(floatscore[][COURSE_NUM],intn,intm){float*psumc,*paver;floattmp;inti,j;if(score[0]==NULL){printf(Pleasepress1inputdata.\n);return;}psumc=(float*)malloc(m*sizeof(float));if(psumc==NULL)exit(1);paver=(float*)malloc(m*sizeof(float));if(paver==NULL){free(psumc);psumc=NULL;exit(1);}for(j=0;jm;j++){psumc[j]=0;for(i=0;in;i++){tmp=*(score[0]+i*m+j);psumc[j]=psumc[j]+tmp;}paver[j]=psumc[j]/n;printf(course%d:sum=%.0f,aver=%.0f\n,j+1,psumc[j],paver[j]);}free(psumc);psumc=NULL;free(paver);paver=NULL;}voidSortbyScore(longnum[],charname[][MAX_LEN],floatscore[][COURSE_NUM],floatsum[],floataver[],intn,intm,int(*compare)(floata,floatb)){inti,j,k;if(score[0]==NULL){printf(Pleasepress1inputdata.\n);return;}if(sum[0]0.0001){printf(pleasepress3Caculatetotalandaveragescoreofever
本文标题:学生成绩管理系统v4.0
链接地址:https://www.777doc.com/doc-5670014 .html