c++成绩管理系统.doc_第1页
c++成绩管理系统.doc_第2页
c++成绩管理系统.doc_第3页
c++成绩管理系统.doc_第4页
c++成绩管理系统.doc_第5页
已阅读5页,还剩10页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

#include#include#include#includeconst int M = 20;class stucopy/此类用于拷贝student的数据,用于排序功能的实现public:char id20;char sex10;char name10;double grade5;double sumsum;/总成绩double average;/平均成绩;class student/用于保存学生信息的类friend class list;public:char id20;/保存学号char sex10;/保存性别char name10;/保存名字double grade5;/保存成绩student()next=0;for (int i=0;i20;i+) idi=0;for (i=0;i10;i+) sexi=0;for (i=0;i10;i+) namei=0;void s();void setid(char id120)for(int i=0;i20;i+)idi=id1i;void setsex(char sex110)for(int i=0;i10;i+)sexi=sex1i;void setname(char name110)for(int i=0;i10;i+)namei=name1i;void setgrade(double grade15)for(int i=0;i5;i+)gradei=grade1i;student *next;/next指向下一个学生,构成链表char * outid()return id;char * outsex()return sex;char * outname()return name;double outsum()double sum=0;for(int i=0;ioutgrade(i);return sum;double outav()return this-outsum()/5;double outgrade(int i)return gradei;void intgrade(int);void student:intgrade(int j)/用于修改学生的成绩 switch (j)case 1:coutgrade0;break;case 2:coutgrade1;break;case 3:coutgrade2;break;case 4:coutgrade3;break;case 5:coutgrade4;break;void student:s()/用于录入学生的信息coutid;coutname;coutsex;coutgrade0;coutgrade1;coutgrade2;coutgrade3;coutgrade4;class list/此类为链表private:double high5,low5;public:student *last,*first;/链表的开头和结尾double totoal;list()last=0;first=0;list();void instu();/新建一个学生的数据void outstu(char *);/根据姓名输出一个学生的信息int delstu(char *n);/根据姓名删除一个学生的信息void outstu1(char *);/根据学号输出一个学生的信息int delstu1(char *n);/根据学号删除一个学生的信息void outsum(char *);/根据姓名输出一个学生的总成绩和平均成绩void outsum1(char *);/根据学号输出一个学生的总成绩和平均成绩void think();/用于输出班级成绩的统计分析void search(char s10,int);/根据姓名修改一个学生的成绩void search1(char s20,int);/根据学号修改一个学生的成绩double hi(int i);/求某门课的最高分double lo(int i);/求某门课的最低分void av(int i);/求某门课的平均分void ev(int i);/用于班级成绩统计分析的人数分布输出void scanall();/输出所有学生的信息;list:list()/析构函数,将所有创建的学生对象删掉if(first!=0)student *p=first,*temp;while(p!=NULL)temp=p;p=p-next;delete temp;couts();if(first=0)first=last=p;elselast-next=p;last=p;void list:utstu(char *n)if(first=0) cout班级无成员!查无此人!next)if(strcmp(temp-outname(),n)=0) coutsetw(8)学号setw(8)姓名setw(6)性别setw(6)数学setw(6)英语setw(6)政治setw(14)程序设计基础setw(6)物理endl;coutsetw(8)outid()setw(8)outname()setw(6)outsex()setw(6)outgrade(0)setw(6)outgrade(1)setw(6)outgrade(2)setw(14)outgrade(3)setw(6)outgrade(4);return;cout查无此人!endl;return;void list:outstu1(char *n)if(first=0) cout班级无成员!查无此人!next)if(strcmp(temp-outid(),n)=0) coutsetw(8)学号setw(8)姓名setw(6)性别setw(6)数学setw(6)英语setw(6)政治setw(14)程序设计基础setw(6)物理endl;coutsetw(8)outid()setw(8)outname()setw(6)outsex()setw(6)outgrade(0)setw(6)outgrade(1)setw(6)outgrade(2)setw(14)outgrade(3)setw(6)outgrade(4);return;cout查无此人!endl;return;int list:delstu(char *n)if(first=0) cout无数据!outname(),n)=0) first=first-next;delete temp;coutnext!=NULL;temp=temp-next)if(strcmp(temp-next-outname(),n)=0)p=temp-next;temp-next=temp-next-next;delete p;coutn删除成功n;return 0;coutn查无此人,删除失败n;return 0;int list:delstu1(char *n)if(first=0) cout无数据!outid(),n)=0) first=first-next;delete temp;coutnext!=NULL)if(strcmp(temp-next-outid(),n)=0)p=temp-next;temp-next=temp-next-next;delete p;coutnext;coutn查无此人,删除失败n;return 0;void list:think()if(first=0) cout无数据!next;i+;totoal=i;cout人数:iendl;cout数学n;cout最高分:hi(0) 最低分:lo(0) 平均分:;av(0);ev(0);cout英语n;cout最高分:hi(1) 最低分:lo(1) 平均分:;av(1);ev(1);cout政治n;cout最高分:hi(2) 最低分:lo(2) 平均分:;av(2);ev(2);cout程序设计基础n;cout最高分:hi(3) 最低分:lo(3) 平均分:;av(3);ev(3);cout物理n;cout最高分:hi(4) 最低分:lo(4) outgrade(i)highi)highi=temp-outgrade(i);temp=temp-next;return highi;double list:lo(int i)lowi=100;student *temp=first;while(temp!=0)if(temp-outgrade(i)outgrade(i);temp=temp-next;return lowi;void list:av(int i)double aver=0;student *temp=first;while(temp!=NULL)aver+=temp-outgrade(i);temp=temp-next;coutaver/totoaloutgrade(i)/10)case 10:a+;break;case 9:a+;break;case 8:b+;break;case 7:c+;break;case 6:d+;break;case 5:e+;break;default:f+;temp=temp-next;cout100-90的人数:a 89-80的人数:b 79-70的人数:c 69-60的人数:d 59-50的人数:e 50以下的人数:f 及格的人数:(a+b+c+d) 不及格的人数:(e+f)next)if(strcmp(temp-outname(),s)=0)temp-intgrade(n);void list:search1(char s20,int n)student *temp=first;for(;temp!=NULL;temp=temp-next)if(strcmp(temp-outid(),s)=0)temp-intgrade(n);void list:outsum(char *n)if(first=0) cout无数据!next)if(strcmp(temp-outname(),n)=0)coutsetw(8)学号setw(8)姓名setw(8)性别setw(8)总成绩setw(10)平均成绩n;coutsetw(8)outid()setw(8)outname()setw(8)outsex()setw(8)outsum()setw(10)outav();return;cout查无此人!endl;return;void list:outsum1(char *n)double sum=0;int i=0;double av=0;if(first=0) cout无数据!next)if(strcmp(temp-outid(),n)=0)coutsetw(8)学号setw(8)姓名setw(8)性别setw(8)总成绩setw(10)平均成绩n;coutsetw(8)outid()setw(8)outname()setw(8)outsex()setw(8)outsum()setw(10)outav();return;cout查无此人!next)coutsetw(8)outid()setw(8)outname()setw(6)outsex()setw(6)outgrade(0)setw(6)outgrade(1)setw(6)outgrade(2)setw(14)outgrade(3)setw(6)outgrade(4)setw(8)outsum()setw(10)outav()endl;void main()stucopy stuM;/复制整个链表的数据于数组,用于排序stucopy stutemp;/临时变量list will;/整个链表student *p, *p1=new student(),*q;/临时变量ifstream input;/输入ofstream output;/输出char file20,classname20,temp80,id20,name9,sex110;/临时变量int m=0,n=0,j=0,i=0;/临时变量double grade15;/临时变量for(i=0;i20;i+) idi=0;for(i=0;i9;i+) namei=0;/初始化docout/-n 0、 退出系统。n 1、 成绩录入:n 2、 成绩查询:n 3、 成绩修改:n 4、 数据删除:n 5、 成绩统计分析:n 各个分数段的人数(100-90、89-80、79-70、69-60、59-50、50以下)、及格率。n 6、 总成绩和平均成绩的查询:n 7、 浏览所有学生信息。n 8、 将所有学生信息保存成文件。n 9、 打开指定的数据文件。n 10、 按总成绩排序输出学生信息。n 11、 按学号顺序输出学生信息,保存成文件。n /-n;coutendlm;switch(m)case 1:will.instu();break;case 2:cout1.根据学号查询 2.根据姓名查询endln;switch(n) case 1:coutid;will.outstu1(id);coutn;break;case 2:coutname;will.outstu(name);coutn;break;break;case 3:cout1.根据学号查询 2.根据姓名查询endln;switch(n)case 1:coutid;will.outstu1(id);coutn;coutsetw(6)1.数学setw(6)2.英语setw(6)3.政治 setw(14)4.程序设计基础setw(6)5.物理endl;coutj;will.search1(id,j);break;case 2:coutname;will.outstu(name);coutn;coutsetw(6)1.数学setw(6)2.英语setw(6)3.政治 setw(14)4.程序设计基础setw(6)5.物理endl;coutj;will.search(name,j);break;break;case 4:cout1.根据学号删除 2.根据姓名删除endln;switch(n)case 1:coutid;will.outstu1(id);will.delstu1(id);break;case 2:coutname;will.outstu(name);will.delstu(name);break;break;case 5:will.think();break;case 6:cout1.根据学号查询 2.根据姓名查询endln;switch(n)case 1:coutid;will.outsum1(id);break;case 2:coutname;will.outsum(name);break;break;case 7:coutsetw(8)学号setw(8)姓名setw(6)性别setw(6)数学setw(6)英语setw(6)政治setw(14)程序设计基础setw(6)物理setw(8)总成绩setw(10)平均成绩n;will.scanall();break;case 8:cout请输入文件名:file;cout请输入班级名称:classname;output.open(file);p = will.first;outputclassname成绩单endlsetw(8)学号setw(8)姓名setw(6)性别setw(6)数学setw(6)英语setw(6)政治setw(14)程序设计基础setw(6)物理setw(8)总成绩setw(10)平均成绩next)outputsetw(8)outid()setw(8)outname()setw(6)outsex()setw(6)outgrade(0)setw(6)outgrade(1)setw(6)outgrade(2)setw(14)outgrade(3)setw(6)outgrade(4)setw(8)outsum()setw(10)outav()endl;output.close();break;case 9:cout请输入文件名:file;input.open(file);if (input.fail()coutFile does not existendl;break;input.getline(temp,80); input.getline(temp,80);if(input.eof() cout文件中无数据!idnamesex1grade10grade11grade12grade13grade14;inputtemp;inputtemp;/将总成绩和平均成绩输入进临时变量p1-setid(id);p1-setname(name);p1-setsex(sex1);p1-setgrade(grade1);will.first=p1;will.last=will.first;while(!input.eof()p=new student();q=will.last;will.last-next=p;will.last=p;inputidnamesex1grade10grade11grade12grade13grade14;will.last-setid(id);will.last-setname(name);will.last-setsex(sex1);will.last-setgrade(grade1);inputtemp;inputtemp;/将总成绩和平均成绩输入进临时变量will.last=q;will.last-next=NULL;input.close();break;case 10:p=will.first;for(i=0;inext)for (j=0;jidj;for (j=0;jnamej;for (j=0;jsexj;stui.sumsum=p-outsum();stui.average=p-outav();for(n=0;ni-1;n+)for(j=1;ji;j+)if (stun.sumsumstuj.sumsum)stutemp=stuj;stuj=stun;stun=stutemp;coutsetw(8)学号setw(8)姓名setw(6)性别setw(8)总成绩setw(10)平均成绩n;for (j=0;ji;j+)coutsetw(8)stuj.idsetw(8)setw(6)stuj.sexsetw(8)stuj.sumsumsetw(10)stuj.averageendl;break;case 11:p=will.first;for(i=0;inext)for (j=0;jidj;for (j=0;jnamej;for (j=0;jsexj;stui.sumsum=p-outsum();s

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论