1、/成绩管理系统v1.0 / 能动1302 王清栋 #include #include #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);v
2、oid 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
3、.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 ascend
4、ing 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); b
5、reak; 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);
6、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
7、); 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;in;i+) printf(Input students ID and score); scanf(%ld,&numi);
8、for(j=0;jm;j+) scanf(%d,&scoreij); void Totalave (int scoreM,int n,int m) /2.计算每门课程总分和平均分 int i,j,sumM; double aveM; for(j=0;jm;j+) sumj=0; for(i=0;in;i+) sumj=sumj+scoreij; avej=(double)sumj/n; for(i=0;im;i+) printf(科目%d总分=%d,课程平均分=%fn,i+1,sumi,avei);void evestuTotalave (int scoreM,int n,int m,long
9、 num) /3.计算每个学生总分和平均分 int i,j,sumN; double aveN; for(i=0;in;i+) sumi=0; for(j=0;jm;j+) sumi=sumi+scoreij; avei=(double)sumi/m; for(i=0;in;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;in;i+) sumi=0; for
10、(j=0;jm;j+) sumi=sumi+scoreij; for(i=0;in;i+) k=i; for(j=i+1;jsumk) k=j; if(i!=k) t=sumk,h=numk; sumk=sumi,numk=numi; sumi=t,numi=h; for(i=0;in;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;in;i+)
11、 sumi=0; for(j=0;jm;j+) sumi=sumi+scoreij; for(i=0;in;i+) k=i; for(j=i+1;jn;j+) if (sumjsumk) k=j; if(i!=k) t=sumk,h=numk; sumk=sumi,numk=numi; sumi=t,numi=h; for(i=0;in;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;
12、 for(i=0;in;i+) k=i; for(j=i+1;jn;j+) if (numjnumk) k=j; if(i!=k) h=numk; numk=numi; numi=h; for(l=0;lm;l+) tl=scorekl; scorekl=scoreil; scoreil=tl; for(i=0;in;i+) printf(ID:%10ldn,numi);/以长整形打印用%ld for(j=0;jm;j+) printf(project %d score:%dn,j+1,scoreij); void Search (long num,int scoreM,int n,int x
13、,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;in;i+) sumi=0; for(j=0;jm;j+) sumi=sumi+scoreij; for(i=0;in;i+) k=i; for(j=i+1;jn;j+) if (numjnumk) k=j; if(i!=k) h=numk,o=sumk; numk=numi,sumk=sumi; numi=h,sumi=o; for(l=0;lm;l+) tl=scorekl; scorekl=scorei
14、l; scoreil=tl; while(find=0&lownummid) low=mid+1; else if(xnummid) high=mid-1; else pos=mid; find=1; if(find=0) printf(not findn); else for(i=0;isumpos) c+; printf(ID:%10ldn,numpos);/以长整形打印用%ld for(j=0;jm;j+) printf(project %d score:%dn,j+1,scoreposj); printf(all score:%d,order:%dn,sumpos,c); void s
15、tatistis (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;jm;j+) for(i=0;i=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*10
16、0; 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;in;i+) sumi=0; for(j=0;jm;j+) sumi=sumi+scoreij; avei=(double)sumi/m; for(i=0;in;i+) printf(ID:%10ldn,numi); for(j=0;jm;j+) printf(score:%dn,scoreij); printf(总分=%dn平均分%fn,sumi,avei);
©2010-2024 宁波自信网络信息技术有限公司 版权所有
客服电话:4008-655-100 投诉/维权电话:4009-655-100