您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 项目/工程管理 > 学生成绩管理系统-V-2.0
#includestdio.h#defineN30voidrecord(intn,intscore[],longnumber[]);floattotal_average(intscore[],intn,int*psum);voiddes_as(intn,intscore[],longnumber[],int(*compare)(inta,intb));intas(inta,intb);intdes(inta,intb);voidasnumber(intn,intscore[],longnumber[]);voidswap(int*x,int*y);intchaxun(longnumber[],intn,intstudentnumber);voidfenleibai(intn,intscore[],intylzjb[]);main(){intn,m;intj=0;inth;longstudentnumber;floati;intsum=0;int*psum=∑intscore[N]={0};longnumber[N]={0};intylzjb[N]={0};printf(pleaseinputthenumberofstudent:);scanf(%d,&n);do{printf(1.Inputrecord\n);printf(2.Caculatetotalandaveragescoreofcpurse\n);printf(3.Sortindescenfingorderbyscore\n);printf(4.Sortinascendingorderbyscore\n);printf(5.Sortinascenfingorderbynumber\n);printf(6.Searchbynumber\n);printf(7.Statisticanalysis\n);printf(8.Listrecord\n);printf(0.Exit\n);printf(Pleaseenteryourchoice:);scanf(%d,&m);switch(m){case1:record(n,score,number);break;case2:i=total_average(score,n,&sum);printf(totalis%d,averageis%.1f\n,*psum,i);break;case3:des_as(n,score,number,des);for(j=0;jn;j++){printf(µÚ%dÃû%d%d\n,j+1,number[j],score[j]);}break;case4:des_as(n,score,number,as);for(j=0;jn;j++){printf(µÚ%dÃû%d%d\n,n-j,number[j],score[j]);}break;case5:asnumber(n,score,number);for(j=0;jn;j++){printf(%d%d\n,number[j],score[j]);}break;case6:asnumber(n,score,number);printf(pleaseiinputstudentnumber:);scanf(%ld,&studentnumber);h=chaxun(number,n,studentnumber);if(h==-1){printf(studentnumberiserror);}else{printf(ÅÅÃû%d,³É¼¨%d\n,h+1,score[h]);}break;case7:fenleibai(n,score,ylzjb);printf(ÓÅÐãÓÐ%d¸ö,Õ¼%.2f%%\n,ylzjb[0],(float)(100/n)*ylzjb[0]);printf(Á¼ºÃÓÐ%d¸ö,Õ¼%.2f%%\n,ylzjb[1],(float)(100/n)*ylzjb[1]);printf(ÖеÈÓÐ%d¸ö,Õ¼%.2f%%\n,ylzjb[2],(float)(100/n)*ylzjb[2]);printf(¼°¸ñÓÐ%d¸ö,Õ¼%.2f%%\n,ylzjb[3],(float)(100/n)*ylzjb[3]);printf(²»¼°¸ñÓÐ%d¸ö,Õ¼%.2f%%\n,ylzjb[4],(float)(100/n)*ylzjb[4]);break;case8:for(j=0;jn;j++){printf(%d%d\n,number[j],score[j]);}i=total_average(score,n,&sum);printf(totalis%d,averageis%.1f\n,*psum,i);break;case0:break;}}while(m!=0);}/*º¯Êý¹¦ÄÜ£ºÂ¼ÈëѧÉúѧºÅºÍ³É¼¨*/voidrecord(intn,intscore[],longnumber[]){inti;for(i=0;in;i++){printf(pleaseinputnumber:);scanf(%d,&number[i]);printf(pleaseinputscore:);scanf(%d7,&score[i]);}}/*º¯Êý¹¦ÄÜ£º¼ÆËã¿Î³ÌµÄ×Ü·ÖºÍƽ¾ù·Ö*/floattotal_average(intscore[],intn,int*psum){inti;*psum=0;for(i=0;in;i++){*psum=*psum+score[i];}return(float)(*psum)/n;}/*º¯Êý¹¦ÄÜ£º³É¼¨ÅÅÐò*/voiddes_as(intn,intscore[],longnumber[],int(*compare)(inta,intb)){inti,ret;do{ret=0;for(i=0;in-1;i++){if((*compare)(score[i],score[i+1])){swap(&score[i],&score[i+1]);swap(&number[i],&number[i+1]);ret++;}}}while(ret!=0);}/*º¯Êý¹¦ÄÜ£ºÅжϳɼ¨´óСÅÅÐò·½Ê½*/intas(inta,intb){returnab;}intdes(inta,intb){returnab;}/*º¯Êý¹¦ÄÜ£º½»»»Á½¸öÊý*/voidswap(int*x,int*y){inttemp;temp=*x;*x=*y;*y=temp;}/*º¯Êý¹¦ÄÜ£º°´Ñ§ºÅ´óСÅÅÐò*/voidasnumber(intn,intscore[],longnumber[]){inti,ret;do{ret=0;for(i=0;in-1;i++){if(number[i]number[i+1]){swap(&score[i],&score[i+1]);swap(&number[i],&number[i+1]);ret++;}}}while(ret!=0);}/*º¯Êý¹¦ÄÜ£º²éѯѧÉúÅÅÃûºÍ³É¼¨*/intchaxun(longnumber[],intn,intstudentnumber){inti,ret=0;for(i=0;in;i++){if(number[i]==studentnumber){returni;ret++;}}if(ret==0){return-1;}}/*º¯Êý¹¦ÄÜ£ºÑ§Éú³É¼¨·ÖÀà*/voidfenleibai(intn,intscore[],intylzjb[]){inti;for(i=0;in;i++){if(score[i]=90&&score[i]=100){ylzjb[0]++;}if(score[i]=80&&score[i]=89){ylzjb[1]++;}if(score[i]=70&&score[i]=79){ylzjb[2]++;}if(score[i]=60&&score[i]=69){ylzjb[3]++;}if(score[i]=0&&score[i]=59){ylzjb[4]++;}}}
本文标题:学生成绩管理系统-V-2.0
链接地址:https://www.777doc.com/doc-4482062 .html