新版学生成绩标准管理系统.doc
/成绩管理系统v1.0 / 能动1302 王清栋 #include <stdio.h>#include <stdlib.h>#define N 30#define M 6void Input (long num,int scoreM,int n,int m);void Totalave (int scoreM,int n,int m);void evestuTotalave (int scoreM,int n,int m,long num);void Scoredes (long num,int scoreM,int n,int m);void Scoreas (long num,int scoreM,int n,int m);void Numas (long num,int scoreM,int n,int m);void Search (long num,int scoreM,int n,int x,int m);void statistis (long num,int scoreM,int n,int m);void List (long num,int scoreM,int n,int m);int main() int n,scoreNM,c,x,m; long numN; printf("输入学生人数"); scanf("%d",&n); printf("输入考试科目"); scanf("%d",&m); printf("1.Input recordn"); printf("2.Caculate totel and average score of every coursen"); printf("3.Caculate totel and average score of every studentn"); printf("4.Sort in descending order by total score of every studentn"); printf("5.Sort in ascending order by total score of every studentn"); printf("6.Sort in ascending order by numbern"); printf("7.Search by numbern"); printf("8.Statistic analysis for every coursen"); printf("9.List recordn"); printf("0.Exitn"); printf("Please enter your choice:n"); printf("n"); for(;) scanf("%d",&c); switch(c) case 1: /录入学生学号和各科成绩 Input (num,score,n,m); printf("Please enter your choice:n"); break; case 2: /计算每门课程总分和平均分 Totalave (score,n,m); printf("Please enter your choice:n"); break; case 3: /计算每个学生总分和平均分 evestuTotalave (score,n,m,num); break; case 4: /按每个学生总分由高到低排出名次表 Scoredes (num,score,n,m); printf("Please enter your choice:n"); break; case 5: /按每个学生总分由低到高排出名次表 Scoreas (num,score,n,m); printf("Please enter your choice:n"); break; case 6: /按学号由小到大排出名次表 Numas (num,score,n,m); printf("Please enter your choice:n"); break; case 7: /按学号查询学生排名及其各科成绩 printf("请输入查找学号n"); scanf("%d",&x); Search (num,score,n,x,m); printf("Please enter your choice:n"); break; case 8: /成绩分析 所占比例 statistis (num,score,n,m); printf("Please enter your choice:n"); break; case 9: /所有输出 List (num,score,n,m); Totalave (score,n,m); printf("Please enter your choice:n"); break; case 0: exit(0); return 0;void Input (long num,int scoreM,int n,int m) /1 int i,j; for(i=0;i<n;i+) printf("Input student's ID and score"); scanf("%ld",&numi); for(j=0;j<m;j+) scanf("%d",&scoreij); void Totalave (int scoreM,int n,int m) /2.计算每门课程总分和平均分 int i,j,sumM; double aveM; for(j=0;j<m;j+) sumj=0; for(i=0;i<n;i+) sumj=sumj+scoreij; avej=(double)sumj/n; for(i=0;i<m;i+) printf("科目%d总分=%d,课程平均分=%fn",i+1,sumi,avei);void evestuTotalave (int scoreM,int n,int m,long num) /3.计算每个学生总分和平均分 int i,j,sumN; double aveN; for(i=0;i<n;i+) sumi=0; for(j=0;j<m;j+) sumi=sumi+scoreij; avei=(double)sumi/m; for(i=0;i<n;i+) printf("学号为%ld总分=%d,其平均分=%fn",numi,sumi,avei);void Scoredes (long num,int scoreM,int n,int m) /4.按每个学生总分由高到低排出名次表 int i,j,k,t,h,sumN; for(i=0;i<n;i+) sumi=0; for(j=0;j<m;j+) sumi=sumi+scoreij; for(i=0;i<n;i+) k=i; for(j=i+1;j<n;j+) if (sumj>sumk) k=j; if(i!=k) t=sumk,h=numk; sumk=sumi,numk=numi; sumi=t,numi=h; for(i=0;i<n;i+) printf("ID:%10ld,score:%dn",numi,sumi);/以长整形打印用%ldvoid Scoreas (long num,int scoreM,int n,int m) /5.按每个学生总分由di到gao排出名次表 int i,j,k,t,h,sumN; for(i=0;i<n;i+) sumi=0; for(j=0;j<m;j+) sumi=sumi+scoreij; for(i=0;i<n;i+) k=i; for(j=i+1;j<n;j+) if (sumj<sumk) k=j; if(i!=k) t=sumk,h=numk; sumk=sumi,numk=numi; sumi=t,numi=h; for(i=0;i<n;i+) printf("ID:%10ld,score:%dn",numi,sumi);/以长整形打印用%ldvoid Numas (long num,int scoreM,int n,int m) /6.按学号由小到大排出名次表 int i,j,k,tM,h,l; for(i=0;i<n;i+) k=i; for(j=i+1;j<n;j+) if (numj<numk) k=j; if(i!=k) h=numk; numk=numi; numi=h; for(l=0;l<m;l+) tl=scorekl; scorekl=scoreil; scoreil=tl; for(i=0;i<n;i+) printf("ID:%10ldn",numi);/以长整形打印用%ld for(j=0;j<m;j+) printf("project %d score:%dn",j+1,scoreij); void Search (long num,int scoreM,int n,int x,int m) /7.按学号查询学生排名及其各科成绩 int high=n-1,low=0,mid,c=1,pos,o,find=0,i,j,k,tM,h,sumN,l; for(i=0;i<n;i+) sumi=0; for(j=0;j<m;j+) sumi=sumi+scoreij; for(i=0;i<n;i+) k=i; for(j=i+1;j<n;j+) if (numj<numk) k=j; if(i!=k) h=numk,o=sumk; numk=numi,sumk=sumi; numi=h,sumi=o; for(l=0;l<m;l+) tl=scorekl; scorekl=scoreil; scoreil=tl; while(find=0&&low<=high) mid=(high+low)/2; if(x>nummid) low=mid+1; else if(x<nummid) high=mid-1; else pos=mid; find=1; if(find=0) printf("not findn"); else for(i=0;i<n;i+) if(sumi>sumpos) c+; printf("ID:%10ldn",numpos);/以长整形打印用%ld for(j=0;j<m;j+) printf("project %d score:%dn",j+1,scoreposj); printf("all score:%d,order:%dn",sumpos,c); void statistis (long num,int scoreM,int n,int m) /8. int a=0,b=0,c=0,d=0,e=0,i,j; double A,B,C,D,E; for(j=0;j<m;j+) for(i=0;i<n;i+) if(scoreij>=90) a+; else if(scoreij>=80) b+; else if(scoreij>=70) c+; else if(scoreij>=60) d+; else e+; A=(double)a/n*100; B=(double)b/n*100; C=(double)c/n*100; D=(double)d/n*100; E=(double)e/n*100; printf("project %dn",j+1); printf("先进人数%d,比例:%f%n",a,A); printf("良好人数%d,比例:%f%n",b,B); printf("中档人数%d,比例:%f%n",c,C); printf("及格人数%d,比例:%f%n",d,D); printf("不及格人数%d,比例:%f%n",e,E); void List (long num,int scoreM,int n,int m) int i,j,sumN; double aveN; for(i=0;i<n;i+) sumi=0; for(j=0;j<m;j+) sumi=sumi+scoreij; avei=(double)sumi/m; for(i=0;i<n;i+) printf("ID:%10ldn",numi); for(j=0;j<m;j+) printf("score:%dn",scoreij); printf("总分=%dn平均分%fn",sumi,avei);