《C语言大作业——学生成绩管理系统v2..pdf》由会员分享,可在线阅读,更多相关《C语言大作业——学生成绩管理系统v2..pdf(9页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、/成绩管理系统#include#include#define N 30 void 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 Search(long num,int score,int n,int x);void statistis(long nu
2、m,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(recordn);printf(totel and average score of coursen);printf(in descending order by scoren);printf(in ascending order by numbern);printf(by numbern);printf(analysisn);printf
3、(recordn);printf(n);printf(Please enter your choice:n);printf(n);for(;)scanf(%d,&c);switch(c)case 1:Input(num,score,n);printf(Please enter your choice: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
4、:%dn,numi,scorei);/以长整形打印用%ld printf(Please enter your choice:n);break;case 4:Numas(num,score,n);printf(Please enter your choice:n);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:
5、n);break;case 7:List(num,score,n);Totalave(score,n);printf(Please enter your choice:n);break;case 0:exit(0);return 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;
6、i+)sum=sum+scorei;ave=(double)sum/n;printf(Caculate total=%d,average score of course=%fn,sum,ave);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,n
7、umi=h;int Ascending(int a,int b)return ab;void Numas(long num,int score,int n)int 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);/以长整形打印用%ld void Search(long num,int scor
8、e,int n,int x)int high=n-1,low=0,mid,c=0,pos,find=0,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;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;isc
9、orepos)c+;printf(ID:%10ld,order:%d,score:%dn,numpos,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);