《c语言大作业——学生成绩管理系统v50.pdf》由会员分享,可在线阅读,更多相关《c语言大作业——学生成绩管理系统v50.pdf(9页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、/成绩管理系统 v1.0#include#include#include#define N 30#define M 6typedef struct studentlong studentID;char studentName10;int scoreM;STU;void Input(STU stu,int n,int m);void Totalave(STU stu,int n,int m);void evestuTotalave(STU stu,int n,int m);void Scoredes(STU stu,int n,int m);void Scoreas(STU stu,int n,
2、int m);void Numas(STU stu,int n,int m);void Dicas(STU stu,int n,int m);void Searchbynum(STU stu,int n,int x,int m);void Searchbymane(STU stu,int n,char name,int m);void statistis(STU stu,int n,int m);void List(STU stu,int n,int m);int main()int n,c,x,m;char name10;STU stuN;printf(输入学生人数);scanf(%d,&n
3、);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
4、studentn);printf(6.Sort in ascending order by numbern);printf(7.Sort in ascending order by name);printf(8.Search by numbern);printf(9.Search by namen);printf(10.Statistic analysis for every coursen);printf(11.List recordn);printf(0.Exitn);printf(Please enter your choice:n);printf(n);for(;)scanf(%d,&
5、c);switch(c)case 1:/录入学生学号和各科成绩Input(stu,n,m);printf(Please enter your choice:n);break;case 2:/计算每门课程的总分和平均分Totalave(stu,n,m);printf(Please enter your choice:n);break;case 3:/计算每个学生的总分和平均分evestuTotalave(stu,n,m);break;case 4:/按每个学生的总分由高到低排出名次表Scoredes(stu,n,m);printf(Please enter your choice:n);brea
6、k;case 5:/按每个学生的总分由低到高排出名次表Scoreas(stu,n,m);printf(Please enter your choice:n);break;case 6:/按学号由小到大排出名次表Numas(stu,n,m);printf(Please enter your choice:n);break;case 7:/按姓名的字典顺序排出成绩表Dicas(stu,n,m);printf(Please enter your choice:n);break;case 8:/按学号查询学生排名及其各科成绩printf(请输入查找学号n);scanf(%d,&x);Searchbyn
7、um(stu,n,x,m);printf(Please enter your choice:n);break;case 9:/按姓名查询学生排名及其各科成绩printf(请输入查找姓名n);scanf(%s,name);getchar();Searchbymane(stu,n,name,m);printf(Please enter your choice:n);break;case 10:/成绩分析所占百分比statistis(stu,n,m);printf(Please enter your choice:n);break;case 11:/全部输出List(stu,n,m);Totalav
8、e(stu,n,m);printf(Please enter your choice:n);break;case 0:exit(0);return 0;void Input(STU stu,int n,int m)/1int i,j;for(i=0;in;i+)printf(Input students ID,name and score);scanf(%ld,&stui.studentID);scanf(%s,stui.studentName);for(j=0;jm;j+)scanf(%d,&stui.scorej);void Totalave(STU stu,int n,int m)/2.
9、计算每门课程的总分和平均分int i,j,sumM;double aveM;for(j=0;jm;j+)sumj=0;for(i=0;in;i+)sumj=sumj+stui.scorej;avej=(double)sumj/n;for(i=0;im;i+)printf(科目%d 的总分=%d,课程的平均分=%fn,i+1,sumi,avei);void evestuTotalave(STU stu,int n,int m)/3.计算每个学生的总分和平均分int i,j,sumN;double aveN;for(i=0;in;i+)sumi=0;for(j=0;jm;j+)sumi=sumi+
10、stui.scorej;avei=(double)sumi/m;for(i=0;in;i+)printf(学号为%ld,姓名为%s的总分=%d,其平均分=%fn,stui.studentID,stui.studentName,sumi,avei);void Scoredes(STU stu,int n,int m)/4.按每个学生的总分由高到低排出名次表int i,j,k,h,sumN;STU t;for(i=0;in;i+)sumi=0;for(j=0;jm;j+)sumi=sumi+stui.scorej;for(i=0;in;i+)k=i;for(j=i+1;jsumk)k=j;if(i
11、!=k)t=stui,h=sumi;stui=stuk,sumi=sumk;stuk=t,sumk=h;for(i=0;in;i+)printf(ID:%10ld,name:%s,score:%dn,stui.studentID,stui.studentName,sumi);/以长整形打印用%ldvoid Scoreas(STU stu,int n,int m)/5.按每个学生的总分由 di 到 gao 排出名次表int i,j,k,h,sumN;STU t;for(i=0;in;i+)sumi=0;for(j=0;jm;j+)sumi=sumi+stui.scorej;for(i=0;in;
12、i+)k=i;for(j=i+1;jn;j+)if(sumjsumk)k=j;if(i!=k)t=stui,h=sumi;stui=stuk,sumi=sumk;stuk=t,sumk=h;for(i=0;in;i+)printf(ID:%10ld,name:%s,score:%dn,stui.studentID,stui.studentName,sumi);/以长整形打印用%ldvoid Numas(STU stu,int n,int m)/6.按学号由小到大排出名次表int i,j,k;STU t;for(i=0;in;i+)k=i;for(j=i+1;jn;j+)if(stuj.stud
13、entIDstuk.studentID)k=j;if(i!=k)t=stuk,stuk=stui,stui=t;for(i=0;in;i+)printf(ID:%10ld,name:%sn,stui.studentID,stui.studentName);/以 长 整 形 打 印用%ldfor(j=0;jm;j+)printf(project%d score:%dn,j+1,stui.scorej);void Dicas(STU stu,int n,int m)/7.int i,j;STU t;for(i=0;in;i+)for(j=i+1;j0)t=stui,stui=stuj,stuj=t
14、;for(i=0;in;i+)printf(ID:%10ld,name:%sn,stui.studentID,stui.studentName);for(j=0;jm;j+)printf(project:%d,score:%dn,j+1,stui.scorej);void Searchbynum(STU stu,int n,int x,int m)/8.按学号查询学生排名及其各科成绩int i,j,c=1,find=0,sumN;for(i=0;in;i+)sumi=0;for(j=0;jm;j+)sumi=sumi+stui.scorej;for(i=0;in;i+)if(stui.stud
15、entID=x)find=1;break;if(find=0)printf(not findn);elsefor(j=0;jsumi)c+;printf(ID:%10ld name:%sn,stui.studentID,stui.studentName);/以长整形打印用%ldfor(j=0;jm;j+)printf(project%d score:%dn,j+1,stui.scorej);printf(all score:%d,order:%dn,sumi,c);void Searchbymane(STU stu,int n,char name,int m)/9int i,j,c=1,fin
16、d=0,sumN;for(i=0;in;i+)sumi=0;for(j=0;jm;j+)sumi=sumi+stui.scorej;for(i=0;in;i+)if(strcmp(stui.studentName,name)=0)find=1;break;if(find=0)printf(not findn);elsefor(j=0;jsumi)c+;printf(ID:%10ld,name:%sn,stui.studentID,stui.studentName);/以长整形打印用%ldfor(j=0;jm;j+)printf(project%d score:%dn,j+1,stui.scor
17、ej);printf(all score:%d,order:%dn,sumi,c);void statistis(STU stu,int n,int m)/10.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(stui.scorej=80)b+;else if(stui.scorej=70)c+;else if(stui.scorej=60)d+;elsee+;A=(double)a/n*100;B=(double)b/n*100;C=(double)c/n*100;D=(do
18、uble)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(STU stu,int n,int m)/11.int i,j,sumN;double aveN;for(i=0;in;i+)sumi=0;for(j=0;jm;j+)sumi=sumi+stui.scorej;avei=(double)sumi/m;for(i=0;in;i+)printf(ID:%10ld,name:%sn,stui.studentID,stui.studentName);for(j=0;jm;j+)printf(score:%dn,stui.scorej);printf(总分=%dn 平均分%fn,sumi,avei);