《C语言大作业——学生成绩管理系统v2.0.doc》由会员分享,可在线阅读,更多相关《C语言大作业——学生成绩管理系统v2.0.doc(8页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、如有侵权,请联系网站删除,仅供学习与交流C语言大作业学生成绩管理系统v2.0【精品文档】第 8 页/成绩管理系统v2.0#include #include #define N 30void Input (long num,int score,int n);void Totalave (int score,int n);void Scoredes (long num,int score,int n,int (*compare)(int a,int b);int Ascending (int a,int b);void Numas (long num,int score,int n);void S
2、earch (long num,int score,int n,int x);void statistis (long num,int score,int n);void List (long num,int score,int n);int main() int n,scoreN,c,x,i; long numN; printf(输入学生人数); scanf(%d,&n); printf(1.Input recordn); printf(2.Caculate totel and average score of coursen); printf(3.Sort in descending or
3、der by scoren); printf(4.Sort in ascending order by numbern); printf(5.Search by numbern); printf(6.Statistic analysisn); printf(7.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); printf(Please enter your choic
4、e:n); break; case 2: Totalave (score,n); printf(Please enter your choice:n); break; case 3: Scoredes (num,score,n,Ascending); for(i=0;in;i+) printf(ID:%10ld,score:%dn,numi,scorei);/以长整形打印用%ld printf(Please enter your choice:n); break; case 4: Numas (num,score,n); printf(Please enter your choice:n);
5、break; case 5: printf(请输入查找学号n); scanf(%d,&x); Search (num,score,n,x); printf(Please enter your choice:n); break; case 6: statistis (num,score,n); printf(Please enter your choice:n); break; case 7: List (num,score,n); Totalave (score,n); printf(Please enter your choice:n); break; case 0: exit(0); re
6、turn 0;void Input (long num,int score,int n) int i; for(i=0;in;i+) printf(Input students ID and score); scanf(%ld%d,&numi,&scorei);void Totalave (int score,int n) int i,sum=0; double ave; for(i=0;in;i+) sum=sum+scorei; ave=(double)sum/n; printf(Caculate total=%d,average score of course=%fn,sum,ave);
7、void Scoredes (long num,int score,int n,int(*compare)(int a,int b) int i,j,k,t,h; for(i=0;in;i+) k=i; for(j=i+1;jn;j+) if (*compare)(scorej,scorek) k=j; if(i!=k) t=scorek,h=numk; scorek=scorei,numk=numi; scorei=t,numi=h;int Ascending (int a,int b) return ab;void Numas (long num,int score,int n) int
8、i,j,k,t,h; for(i=0;in;i+) k=i; for(j=i+1;jn;j+) if (numjnumk) k=j; if(i!=k) t=scorek,h=numk; scorek=scorei,numk=numi; scorei=t,numi=h; for(i=0;in;i+) printf(ID:%10ld,score:%dn,numi,scorei);/以长整形打印用%ldvoid Search (long num,int score,int n,int x) int high=n-1,low=0,mid,c=0,pos,find=0,i,j,k,t,h; for(i=
9、0;in;i+) k=i; for(j=i+1;jn;j+) if (numjnumk) k=j; if(i!=k) t=scorek,h=numk; scorek=scorei,numk=numi; scorei=t,numi=h; 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;iscorepos) c+; printf(ID:%10ld,order:%d,score:%dn,num
10、pos,c+1,scorepos);void statistis (long num,int score,int n) int a=0,b=0,c=0,d=0,e=0,i; double A,B,C,D,E; for(i=0;i=90) a+; else if(scorei=80) b+; else if(scorei=70) c+; else if(scorei=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(优秀人数%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 score,int n) int i; for(i=0;in;i+) printf(ID:%10ld,score:%dn,numi,scorei);