数据结构课程设计_第1页
数据结构课程设计_第2页
数据结构课程设计_第3页
数据结构课程设计_第4页
数据结构课程设计_第5页
已阅读5页,还剩12页未读 继续免费阅读

下载本文档

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

文档简介

需求分析说明此题对学生的某门课程成绩管理做一个简单的模拟,为了实现学生成绩的管理与分析,设计一个学生成绩管理系统。学生信息包括:学号、姓名、性别,要确保其信息的准确性。课程的成绩信息有平时成绩、实验成绩、期未成绩、总评成绩,总评成绩=平时成绩*0.4+实验成绩*0.3+期末成绩*0.3,用菜单项选择择方式完成以下功能:〔1〕登记学生成绩;〔2〕插入学生成绩;〔3〕修改学生成绩;〔4〕删除学生成绩;〔5〕查询学生成绩;〔6〕对学生成绩进行排序;〔7〕输出学生成绩。在完成上述根本要求的操作后,要应用功能〔6〕进行测试。总体设计设计功能表如下:〔附:功能解释〕学生成绩管理1、输入学生成绩〔输入学生的根本信息:学号、姓名、性别和成绩信息〕2、插入学生成绩〔按照学号进行所需信息的插入〕3、修改学生成绩〔对其学生信息和成绩信息根据一定的需求进行修改〕4、删除个人信息〔按照学号进行删除〕5、查询个人成绩〔按照学号进行删除〕6、学生成绩排名〔升序排名〕7、查询全体信息〔显示全体学生的学生信息及成绩信息〕8、查看成绩排名〔排名后显示成绩排名〕详细设计系统功能分析:学生信息包括:学号、姓名、性别,要确保其信息的准确性。课程的成绩信息有平时成绩、实验成绩、期未成绩、总评成绩,总评成绩=平时成绩*0.4+实验成绩*0.3+期末成绩*0.3,以及功能上述功能。在完成上术根本要求的操作后,要应用功能〔6〕进行测试。得出该题目以创立两个类,一个类保存成绩信息:平时成绩、实验成绩、期未成绩、总评成绩,一个类保存学生信息:学号姓名、性别。从功能分析可知该存储方式适合用链表存储结构:此类功能中在未排序前应该以学号为主键,排序后应该以总评成绩为主键。〔1〕定义一个成绩类:classscore{public:〔访问控制属性〕,平时成绩〔floatpeacetime〕,实验成绩〔floatexperiment〕,期末成绩〔floatfinal〕,总评成绩〔floattotal〕}〔2〕定义一个学生类:Classstudentpublic:〔访问控制属性〕,intsno〔学号〕,stringname〔姓名〕stringsex〔性别〕scorecourse〔课程〕student*next〔下一个学生地址指针〕student*registed();//登记学生成绩voidinsert(student*s,inti);//插入学生成绩voidalter(student*s,inti);//修改学生成绩voiddeleted(student*s,inti);//删除学生成绩voidseek(student*s,inti);//查询学生成绩student*sort(student*s);//成绩排序voidprint(student*s);//输出学生成绩voidsortprint(student*s);//排序后的成绩输出;存储结构设计分析学生的信息:学生的信息和成绩信息都储存在一个链表里,每个节点表示一个学生的信息,包括学号,姓名及平时成绩〔floatpeacetime〕,实验成绩〔floatexperiment〕,期末成绩〔floatfinal〕,总评成绩〔floattotal〕等数据项。程序流程图开始开始菜单菜单学生成绩管理学生成绩管理8查看成绩排名7查询全体信息6学生成绩排名5查询个人成绩8查看成绩排名7查询全体信息6学生成绩排名5查询个人成绩4删除个人信息3修改学生成绩2插入学生成绩1输入学生成绩退出退出代码#include<iostream>#include<iomanip>#include<string>usingnamespacestd;classscore{public:floatpeacetime;//平时成绩floatexperiment;//实验成绩floatfinal;//期末成绩floattotal;//总评成绩};classstudent{public:intsno;//学号stringname;//姓名stringsex;//性别scorecourse;//课程student*next;student*registed();//登记学生成绩voidinsert(student*s,inti);//插入学生成绩voidalter(student*s,inti);//修改学生成绩voiddeleted(student*s,inti);//删除学生成绩voidseek(student*s,inti);//查询学生成绩student*sort(student*s);//成绩排序voidprint(student*s);//输出学生成绩voidsortprint(student*s);//排序后的成绩输出};student*student::registed(){inte;student*hm2,*p,*r;r=hm2=newstudent;hm2->next=NULL;cout<<"输入需要登记的学生的个数:";cin>>e;for(inti=1;i<=e;i++){p=newstudent;cout<<"输入学生的学号:";cin>>p->sno;cout<<"输入学生姓名:";cin>>p->name;cout<<"输入学生性别:";cin>>p->sex;cout<<"输入平时成绩";cin>>p->course.peacetime;cout<<"输入实验成绩";cin>>p->course.experiment;cout<<"输入期末成绩";cin>>p->course.final;p->course.total=static_cast<float>(p->course.peacetime*0.4+p->course.experiment*0.3+p->course.final*0.3);cout<<"课程的总评成绩:"<<p->course.total<<endl;hm2->next=p;hm2=p;}hm2->next=NULL;returnr;}voidstudent::insert(student*s,inti){student*p,*q;p=s;while((p->next!=NULL)&&(p->next->sno<i))p=p->next;q=newstudent;q->sno=i;cout<<"输入学生姓名:";cin>>q->name;cout<<"输入学生性别:";cin>>q->sex;cout<<"输入平时成绩";cin>>q->course.peacetime;cout<<"输入的实验成绩";cin>>q->course.experiment;cout<<"输入期末成绩";cin>>q->course.final;q->course.total=static_cast<float>(q->course.peacetime*0.4+q->course.experiment*0.3+q->course.final*0.3);cout<<endl;cout<<"课程的总评成绩:"<<q->course.total<<endl;q->next=p->next;p->next=q;}voidstudent::alter(student*s,inti){student*p;p=s;while((p->next!=NULL)&&(p->next->sno!=i))p=p->next;if(p->next==NULL){ cout<<"未找到学号,修改失败。"<<endl; return;}else{ cout<<"学生学号:"<<p->next->sno<<endl; cout<<"学生姓名:"<<p->next->name<<endl; cout<<"学生性别:"<<p->next->sex<<endl; cout<<"输入平时成绩"; cin>>p->next->course.peacetime; cout<<"输入实验成绩"; cin>>p->next->course.experiment; cout<<"输入期末成绩"; cin>>p->next->course.final; p->next->course.total=static_cast<float>(p->next->course.peacetime*0.4+p->next->course.experiment*0.3+p->next->course.final*0.3); cout<<endl; cout<<"课程的总评成绩:"<<p->next->course.total<<endl;}}voidstudent::deleted(student*s,inti){student*p;p=s;while((p->next!=NULL)&&(p->next->sno!=i)){p=p->next;}if(p->next==NULL){ cout<<"没有该学号。"<<endl;return;}p->next=p->next->next;}voidstudent::seek(student*s,inti){student*p;p=s;while((p->next!=NULL)&&(p->next->sno!=i))p=p->next;if(p->next==NULL){ cout<<"未找到该学生信息"<<endl; return;}else{ cout<<"学生学号:"<<p->next->sno<<endl; cout<<"学生姓名:"<<p->next->name<<endl; cout<<"学生性别:"<<p->next->sex<<endl; cout<<"平时成绩"<<p->next->course.peacetime<<endl; cout<<"实验成绩"<<p->next->course.experiment<<endl; cout<<"期末成绩"<<p->next->course.final<<endl; cout<<"总评成绩:"<<p->next->course.total<<endl;}}voidstudent::print(student*s){student*p;p=s->next;if(p==NULL) cout<<"当前没有学生信息。"<<endl;else do {cout<<"学生学号:"<<p->sno<<endl;cout<<"学生姓名:"<<p->name<<endl;cout<<"学生性别:"<<p->sex<<endl;cout<<"平时成绩"<<p->course.peacetime<<endl;cout<<"实验成绩"<<p->course.experiment<<endl;cout<<"期末成绩"<<p->course.final<<endl;cout<<"总评成绩:"<<p->course.total<<endl;cout<<endl;p=p->next; }while(p!=NULL);}student*student::sort(student*s){ student*t,*m,*s1,*q; chary; t=newstudent; t->next=NULL; q=s->next; if(q==NULL) cout<<"还没有学生信息!"<<endl; else do { m=t; s1=newstudent; s1->name=q->name; s1->sex=q->sex; s1->sno=q->sno; s1->course.peacetime=q->course.peacetime; s1->course.experiment=q->course.experiment; s1->course.final=q->course.final; s1->course.total=q->course.total; while((m->next!=NULL)&&(m->next->course.total>s1->course.total)) m=m->next; s1->next=m->next; m->next=s1; q=q->next; }while(q!=NULL);cout<<"是否输出学生成绩排名?(y/n)"; cin>>y; if(y=='y') sortprint(t); returnt; }voidstudent::sortprint(student*s)//输出排名后的成绩{ student*t; t=s->next; while(t!=NULL) { cout<<"学号:"<<t->sno<<"姓名:"<<t->name<<"性别:"<<t->sex<<"总评:"<<t->course.total<<endl; t=t->next; }}intmain(){ inti,j; chary; studentt; student*hm1; student*hm; hm=NULL; hm1=NULL;loop:cout<<"+++++++++++++学生成绩管理+++++++++++++++"<<endl; cout<<endl;cout<<"1、输入学生成绩"<<endl;cout<<"2、插入学生成绩"<<endl;cout<<"3、修改学生成绩"<<endl;cout<<"4、删除个人信息"<<endl;cout<<"5、查询个人成绩"<<endl;cout<<"6、学生成绩排名"<<endl;cout<<"7、查询全体信息"<<endl;cout<<"8、查看成绩排名"<<endl;cout<<endl;cout<<"输入需要进行操作的前面的序号:";cin>>i; switch(i){ case1:cout<<"登记学生成绩"<<endl;hm=t.registed();break;case2:cout<<"插入学生成绩"<<endl;loop4:cout<<"输入插入成绩的学生的学号:";cin>>j;t.insert(hm,j);cout<<"是否继续插入学生成绩?(y/n)";cin>>y;if(y=='y') gotoloop4;break;case3:cout<<"修改学生成绩"<<endl;loop1:cout<<"输入修改成绩的学生的学号:";cin>>j;t.alter(hm,j); cout<<"是否继续修改?(y/n)"; cin>>y; if(y=='y') gotoloop1;break;case4:cout<<"删除个人成绩"<<endl;loop2:cout<<"输入删除成绩的学生的学号:";cin>>j;t.deleted(hm,j);cout<<"是否继续删除?(y/n)";cin>>y;if(y=='y') gotoloop2;break;case5:cout<<"查询个人成绩"<<endl;loop3:cout<<"输入查询成绩的学生的学号:";cin>>j;t.seek(hm,j);cout<<"是否继续查询学生成绩?(y/n)"; cin>>y;if(y=='y') gotoloop3;break;case6: cout<<"学生成绩排名"<<endl; hm1=t.sort(hm); break;case7: cout<<"查询全体信息"<<endl; t.print(hm); break;case8: if(hm1!=NULL) { cout<<"查看成绩排名"<<endl; t.sortprint(hm1); } else cout<<"还未进行排名"; break;default:cout<<"输入有误";} cout<<endl<<"是否返回主页面继续管理操作?"<<endl; cout<<"yesorno(y/n)?"<<endl; cin>>y; if(y=='y') {system("cls");gotoloop;} else { system("cls"); cout<<endl<<endl<<endl<<endl<<endl<<endl; cout<<endl<<setw(6)<<"****************欢送下次光临!**************"<<endl; system("pause"); return0; }}程序测试程序界面输入学生成绩插入学生成绩〔插入学号为05的学生的学生信息及成绩信息〕查看结果:修改学生成绩修改后的删除个人信息已删除学号为1的学生信息查询个人成绩学生成绩排名查询全体信息查看成绩排名总结通过这次的课程设计,知道做一个程序设计,真的不容易

温馨提示

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

评论

0/150

提交评论