c++大作业学生信息管理系统源代码.pdf
学生信息管理系统源代码:#include#include#include#include#include#includestruct studentchar num30;int maths;char name30;int chinese;char clas30;int english;int total;float average;student*next;/1(1)void createlist(student*&head)/学生成绩文件导入功能(用链表储存)char t80,num030,name030,clas030;int chinese0,maths0,english0;student*s,*p;ifstream instuf(student-score.txt,ios:in);if(!instuf)cerrfile could not be open.num0name0clas0chinese0maths0english0)s=new student;strcpy(s-num,num0);strcpy(s-name,name0);strcpy(s-clas,clas0);s-chinese=chinese0;s-maths=maths0;s-english=english0;s-total=s-chinese+s-maths+s-english;s-average=float(s-total)/3;if(head=NULL)head=s;else p-next=s;p=s;p-next=NULL;instuf.close();/1(2)void showlist(student*head)/学生成绩信息显示功能(遍历链表)int n=1;cout学号姓名班级语文数学英语总分while(head)均分序号;coutnumnametclast chinesetmathstenglishttotaltsetprecision(3)averaget nnext;/2void charu(student*head)/学生成绩信息插入功能(链表尾部插入学生成绩信息)student*s,*p,*q;int n,i;coutn;cout请输入需插入的学生成绩信息(每人一行):endl;cout学号姓名班级语文数学英语next;for(i=1;is-nums-names-class-chineses-mathss-english;s-total=s-chinese+s-maths+s-english;s-average=float(s-total)/3;q-next=s;q=s;q-next=NULL;/3void shanchu(student*&head)/学生成绩信息删除功能student*p,*q;char a30;int n,i,b=1;coutn;cout请输入需要删除的学生的学号或姓名:endl;for(i=1;ia;if(strcmp(head-num,a)=0)|(strcmp(head-name,a)=0)b=0;p=head;head=head-next;delete p;p=NULL;elsep=head;while(p-next!=NULL)&(strcmp(p-next-num,a)!=0)&(strcmp(p-next-name,a)!=0)p=p-next;if(p-next!=NULL)b=0;q=p-next;p-next=q-next;delete q;q=NULL;if(b=1)cout无此学号或姓名的成绩记录!endl;/4void change(student*head)/学生成绩信息的修改功能(修改指定学生信息)char a30;int b=1;couta;while(head)if(strcmp(head-num,a)=0)|(strcmp(head-name,a)=0)coutendl;b=0;cout此学生原来的学生成绩信息是:endl;cout学号姓名班级语文数学英语endl;coutnumnametclast chinesetmathstenglishendl;cout请输入修改后的学生成绩信息:endl;cout学号姓名班级语文数学英语head-numhead-namehead-clashead-chinesehead-mathshead-english;head-total=head-chinese+head-maths+head-english;head-average=float(head-total)/3;head=head-next;if(b=1)cout无此学号或姓名的成绩记录!endl;/5(1)void geren(student*head)/查询个人成绩功能char a30;int b=1;couta;cout此学生的学生成绩信息是:endl;cout学号姓名班级语文数学英语总分均分num,a)=0)|(strcmp(head-name,a)=0)b=0;coutnumnametclast chinesenext;if(b=1)cout无此学号或姓名的成绩记录!endl;/5(2)void chabanji(student*head)/查询班级成绩功能char a30;int b=1;couta;cout此班级的学生成绩信息是:endl;cout学号姓名班级语文数学英语总分均分clas,a)=0)b=0;coutnumnametclast chinesetmathstenglishttotaltsetprecision(3)averageendl;mathstenglishttotaltsetprecision(3)averagenext;if(b=1)cout无此班级的成绩记录!endl;/5(3)void chayuwen(student*head)/查询语文成绩功能int h,l,b=1;cout请输入您要查询的【语文】成绩的分数段:endl;cout起始分终止分l;cinh;cout此分数段的学生语文成绩信息是:endl;cout学号姓名班级语文数学英语总分均分chinese=l)&(head-chinese=h)b=0;coutnumnametclast chinesenext;if(b=1)cout无此分数段的语文成绩记录!endl;/5(4)void chashuxue(student*head)/查询数学成绩功能int h,l,b=1;cout请输入您要查询的【数学】成绩的分数段:endl;cout起始分终止分l;cinh;cout此分数段的学生数学成绩信息是:endl;cout学号姓名班级语文数学英语总分均分maths=l)&(head-maths=h)b=0;coutnumnametclast chinesenext;if(b=1)cout无此分数段的数学成绩记录!endl;mathstenglishttotaltsetprecision(3)averageendl;mathstenglishttotaltsetprecision(3)averageendl;/5(5)void chayingyu(student*head)/查询英语成绩功能int h,l,b=1;cout请输入您要查询的【英语】成绩的分数段:endl;cout起始分终止分l;cinh;cout此分数段的学生英语成绩信息是:endl;cout学号姓名班级语文数学英语总分均分english=l)&(head-english=h)b=0;coutnumnametclast chinesenext;if(b=1)cout无此分数段的英语成绩记录!endl;/5(6)void chazongfen(student*head)/查询总分成绩功能int h,l,b=1;cout请输入您要查询的【总分】成绩的分数段:endl;cout起始分终止分l;cinh;cout此分数段的学生总分成绩信息是:endl;cout学号姓名班级语文数学英语总分均分total=l)&(head-total=h)b=0;coutnumnametclast chinesenext;if(b=1)cout无此分数段的总分成绩记录!endl;/6(1)void yuwen(student*head)/按语文成绩从高到低排序功能mathstenglishttotaltsetprecision(3)averageendl;mathstenglishttotaltsetprecision(3)averagenext;while(q)if(p-chinesechinese)strcpy(a,p-num);strcpy(p-num,q-num);strcpy(q-num,a);strcpy(a,p-name);strcpy(p-name,q-name);strcpy(q-name,a);strcpy(a,p-clas);strcpy(p-clas,q-clas);strcpy(q-clas,a);b=p-chinese;p-chinese=q-chinese;q-chinese=b;b=p-maths;p-maths=q-maths;q-maths=b;b=p-english;p-english=q-english;q-english=b;b=p-total;p-total=q-total;q-total=b;c=p-average;p-average=q-average;q-average=c;q=q-next;p=p-next;/6(2)void shuxue(student*head)/按数学成绩从高到低排序功能student*p,*q;char a30;int b;float c;p=head;while(p)q=p-next;while(q)if(p-mathsmaths)strcpy(a,p-num);strcpy(p-num,q-num);strcpy(q-num,a);strcpy(a,p-name);strcpy(p-name,q-name);strcpy(q-name,a);strcpy(a,p-clas);strcpy(p-clas,q-clas);strcpy(q-clas,a);b=p-chinese;p-chinese=q-chinese;q-chinese=b;b=p-maths;p-maths=q-maths;q-maths=b;b=p-english;p-english=q-english;q-english=b;b=p-total;p-total=q-total;q-total=b;c=p-average;p-average=q-average;q-average=c;q=q-next;p=p-next;/6(3)void yingyu(student*head)/按英语成绩从高到低排序功能student*p,*q;char a30;int b;float c;p=head;while(p)q=p-next;while(q)if(p-englishenglish)strcpy(a,p-num);strcpy(p-num,q-num);strcpy(q-num,a);strcpy(a,p-name);strcpy(p-name,q-name);strcpy(q-name,a);strcpy(a,p-clas);strcpy(p-clas,q-clas);strcpy(q-clas,a);b=p-chinese;p-chinese=q-chinese;q-chinese=b;b=p-maths;p-maths=q-maths;q-maths=b;b=p-english;p-english=q-english;q-english=b;b=p-total;p-total=q-total;q-total=b;c=p-average;p-average=q-average;q-average=c;q=q-next;p=p-next;/6(4)void zongfen(student*head)/按总分成绩从高到低排序功能student*p,*q;char a30;int b;float c;p=head;while(p)q=p-next;while(q)if(p-totaltotal)strcpy(a,p-num);strcpy(p-num,q-num);strcpy(q-num,a);strcpy(a,p-name);strcpy(p-name,q-name);strcpy(q-name,a);strcpy(a,p-clas);strcpy(p-clas,q-clas);strcpy(q-clas,a);b=p-chinese;p-chinese=q-chinese;q-chinese=b;b=p-maths;p-maths=q-maths;q-maths=b;b=p-english;p-english=q-english;q-english=b;b=p-total;p-total=q-total;q-total=b;q=q-next;p=p-next;/7void xuehao(student*head)/按学号从小到大排序功能student*p,*q;char a30;int b;float c;p=head;while(p)q=p-next;while(q)if(strcmp(p-num,q-num)0)strcpy(a,p-num);strcpy(p-num,q-num);strcpy(q-num,a);c=p-average;p-average=q-average;q-average=c;strcpy(a,p-name);strcpy(p-name,q-name);strcpy(q-name,a);strcpy(a,p-clas);strcpy(p-clas,q-clas);strcpy(q-clas,a);b=p-chinese;p-chinese=q-chinese;q-chinese=b;b=p-maths;p-maths=q-maths;q-maths=b;b=p-english;p-english=q-english;q-english=b;b=p-total;p-total=q-total;q-total=b;c=p-average;p-average=q-average;q-average=c;q=q-next;p=p-next;/8void xingming(student*head)/按姓名首字母排序功能student*p,*q;char a30;int b;float c;p=head;while(p)q=p-next;while(q)if(strcmp(p-name,q-name)0)strcpy(a,p-num);strcpy(p-num,q-num);strcpy(q-num,a);strcpy(a,p-name);strcpy(p-name,q-name);strcpy(q-name,a);strcpy(a,p-clas);strcpy(p-clas,q-clas);strcpy(q-clas,a);b=p-chinese;p-chinese=q-chinese;q-chinese=b;b=p-maths;p-maths=q-maths;q-maths=b;b=p-english;p-english=q-english;q-english=b;b=p-total;p-total=q-total;q-total=b;q=q-next;p=p-next;/9void banji(student*head)/按班级的类别排序功能student*p,*q;char a30;int b;float c;p=head;c=p-average;p-average=q-average;q-average=c;while(p)q=p-next;while(q)if(strcmp(p-clas,q-clas)0)strcpy(a,p-num);strcpy(p-num,q-num);strcpy(q-num,a);strcpy(a,p-name);strcpy(p-name,q-name);strcpy(q-name,a);strcpy(a,p-clas);strcpy(p-clas,q-clas);strcpy(q-clas,a);b=p-chinese;p-chinese=q-chinese;q-chinese=b;b=p-maths;p-maths=q-maths;q-maths=b;b=p-english;p-english=q-english;q-english=b;b=p-total;p-total=q-total;q-total=b;q=q-next;p=p-next;/10void show(student*head,char*s)/学生成绩信息文件导出功能int n=1;ofstream outstuf;outstuf.open(s,ios:out);if(!outstuf)cerrfile could not be open.endl;abort();outstuf学号姓名班级语文数学英语总分均分序号endl;while(head)outstufnumnametclast chinesetmathstenglishttotaltsetprecision(3)averagetnaverage;p-average=q-average;q-average=c;n=n+1;head=head-next;outstuf.close();void main()student*head=NULL;int n;char s30;cout*;cout*欢迎使用学生成绩管理系统*;cout*管理员:*;cout*请选择您想使用的功能:*;cout*功能名请输入功能名请输入*;cout*导入学生成绩文件1按学号小到大排序7*;cout*插入学生成绩信息2按姓名首字母排序8*;cout*删除学生成绩信息3按班级的类别排序9*;cout*修改学生成绩信息4导出学生成绩文件10*;cout*查询学生成绩信息5其它功能.*;cout*按成绩高到低排序6退出管理系统0*;cout*;coutn;createlist(head);while(n0)switch(n)case 1:cout导入的需管理的学生成绩信息表:endl;showlist(head);break;case 2:charu(head);cout插入后的学生成绩信息表:endl;showlist(head);break;case 3:shanchu(head);cout删除后的学生成绩信息表:endl;showlist(head);break;case 4:change(head);cout修改后的学生成绩信息表:endl;showlist(head);break;case 5:cout请选择查询学生成绩的方式:endl;cout方式请输入方式请输入endl;cout 查询个人成绩1查询数学成绩4endl;cout 查询班级成绩2查询英语成绩5endl;cout 查询语文成绩3查询总分成绩6endl;coutn;switch(n)case 1:geren(head);break;case 2:zongfen(head);chabanji(head);break;case 3:yuwen(head);chayuwen(head);break;case 4:shuxue(head);chashuxue(head);break;case 5:yingyu(head);chayingyu(head);break;case 6:zongfen(head);chazongfen(head);break;break;case 6:cout请选择需排序的成绩的类型:endl;cout类型请输入类型cout 按语文成绩排序1按英语成绩排序cout 按数学成绩排序2按总分成绩排序coutn;switch(n)case 1:yuwen(head);cout按【语文】成绩排序后的学生成绩信息表:endl;showlist(head);break;case 2:shuxue(head);cout按【数学】成绩排序后的学生成绩信息表:endl;showlist(head);break;case 3:yingyu(head);cout按【英语】成绩排序后的学生成绩信息表:endl;showlist(head);break;case 4:zongfen(head);cout按【总分】成绩排序后的学生成绩信息表:endl;showlist(head);break;break;case 7:xuehao(head);cout按【学号】从小到大排序后的学生成绩信息表:endl;showlist(head);请输入endl;3endl;4endl;break;case 8:xingming(head);cout按【姓名】首字母排序后的学生成绩信息表:endl;showlist(head);break;case 9:banji(head);cout按【班级】的类别排序后的学生成绩信息表:endl;showlist(head);break;case 10:cout请选择需导出的学生成绩数据文件的内容:endl;cout内容请输入内容请输入;cout 按总分成绩排序的成绩表1按姓名首字母排序的成绩表3;cout 按学号大小排序的成绩表2按班级分类别排序的成绩表4;coutn;switch(n)case 1:zongfen(head);cout按【总分】成绩排序的成绩表已导出endl;cout在生成的total-sort.txt文件中endl;cout请注意查看!endl;strcpy(s,total-sort.txt);show(head,s);break;case 2:xuehao(head);cout按【学号】大小排序的成绩表已导出endl;cout在生成的number-sort.txt 文件中endl;cout请注意查看!endl;strcpy(s,number-sort.txt);show(head,s);break;case 3:xingming(head);cout按【姓名】首字母排序的成绩表已导出endl;cout在生成的name-sort.txt 文件中endl;cout请注意查看!endl;strcpy(s,name-sort.txt);show(head,s);break;case 4:banji(head);cout按【班级】分类排序的成绩表已导出endl;cout在生成的class-sort.txt文件中endl;cout请注意查看!endl;strcpy(s,class-sort.txt);show(head,s);break;break;cout 继续操作请按回车键!endl;cgets(s);coutendlendlendl;cout*;cout*欢迎使用学生成绩管理系统*;cout*管理员:*;cout*请选择您想使用的功能:*;cout*功能名请输入功能名请输入*;cout*导入学生成绩文件1按学号小到大排序7*;cout*插入学生成绩信息2按姓名首字母排序8*;cout*删除学生成绩信息3按班级的类别排序9*;cout*修改学生成绩信息4导出学生成绩文件10*;cout*查询学生成绩信息5其它功能.*;cout*按成绩高到低排序6退出管理系统0*;cout*;coutn;coutendl您所使用的功能已完成,谢谢使用!endl;cout欢迎再次使用!endlendl;