1、/成绩管理系统 v3.0/ 能动 1302 王清栋 1306030217#include #include #include #define N 30void Input (long num,int score,int n,char name10);void Totalave (int score,int n);void Scoredes (long num,int score,int n,char name10);void Scoreas (long num,int score,int n,char name10);void Numas (long num,int score,int n,c
2、har name10);void Nameorder(long num,int score,int n,char name10) ;void Searchbyno (long num,int score,int n,int x,char name10);void Searchbyname(long num,int score,int n,char c,char name10);void statistis (int score,int n);void List (long num,int score,int n,char name10);int main()int n,scoreN,c,x;l
3、ong numN;char nameN10;char y10;printf(“输入学生人数“);scanf(“%d“,/ getchar();printf(“1.Input recordn“);printf(“2.Caculate totel and average score of every coursen“);printf(“3.Sort in descending order by scoren“);printf(“4.Sort in ascending order by score n“);printf(“5.Sort in ascending order by numbern“);
4、printf(“6.Sort in dictionary order by namen“);printf(“7.Search by numbern“);printf(“8.search by namen“);printf(“9.Statistic analysisn“);printf(“10.List recordn“);printf(“0.Exitn“);printf(“Please enter your choice:n“);printf(“n“);for(;)scanf(“%d“,switch(c)case 1: /录入学生学号和各科成绩Input (num,score,n,name);
5、printf(“Please enter your choice:n“);break;case 2: /计算每门课程的总分和平均分Totalave (score,n);printf(“Please enter your choice:n“);break;case 3: /按 chengji 由高到低排出名次表Scoredes (num,score,n,name);printf(“Please enter your choice:n“);break;case 4: /按 chengji 由低到高排出名次表Scoreas (num,score,n,name);printf(“Please ente
6、r your choice:n“);break;case 5: /按学号由小到大排出名次表Numas (num,score,n,name);printf(“Please enter your choice:n“);break;case 6: /按学号由小到大排出名次表Nameorder (num,score,n,name);printf(“Please enter your choice:n“);break;case 7: /按学号查询学生排名及其各科成绩printf(“请输入查找学号n“);scanf(“%d“,Searchbyno (num,score,n,x,name);printf(“
7、Please enter your choice:n“);break;case 8: /按姓名查询学生排名及其各科成绩printf(“请输入查找姓名n“);getchar();gets(y);Searchbyname (num,score,n,y,name);break;printf(“Please enter your choice:n“);case 9: /成绩分析 所占百分比statistis (score,n);printf(“Please enter your choice:n“);break;case 10: /全部输出List (num,score,n,name);printf(
8、“Please enter your choice:n“);break;case 0:exit(0);return 0;void Input (long num,int score,int n,char name10) /1int i;for(i=0;iscorek)k=j;if(i!=k)t=scorek,h=numk,strcpy(temp,namek);scorek=scorei,numk=numi,strcpy(namek,namei);scorei=t,numi=h,strcpy(namei,temp);for(i=0;i0)t=scorek,h=numk,strcpy(temp,n
9、amek);scorek=scorei,numk=numi,strcpy(namek,namei);scorei=t,numi=h,strcpy(namei,temp);for(i=0;inummid)low=mid+1;else if(xscorepos)c+;printf(“ID:%10ld,name:%s,order:%d,“,numpos,namepos,c);/以长整形打印用%ldprintf(“score:%dn“,scorepos);void Searchbyname(long num,int score,int n,char c,char name10)/8。按姓名查询学生排名
10、及其考试成绩int i,pos=-1,d=1;for(i=0;iscorepos)d+;printf(“ID:%10ld,name:%s,order:%d,“,numpos,namepos,d);/以长整形打印用%ldprintf(“score:%dn“,scorepos);void statistis (int score,int n) /9.案优秀良好中等及格不及格 5 个类别,统计每个类别的人数以及所占的百分比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(sc
11、orei=70)c+;else if(scorei=60)d+;elsee+;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,char name10) /10 输出每个学生的学号,考试成绩姓名,以及课程总分和平均分int i,sum=0;double ave;for(i=0;in;i+)sum=sum+scorei;ave=(double)sum/n;for(i=0;in;i+)printf(“ID:%10ld,name:%s,score:%dn“,numi,namei,scorei);printf(“总分=%dn 平均分 %fn“,sum,ave);