


版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、课程设计问题描述学院教学信息管理系统是高等学校教务管理的重要组成部分,其内容较多,为了简化计论,要求设计的管理系统能够完成以下功能:1输入:输入每一位教师记录,将其信息写入文件中;2显示:显示每位教师记录;3排序:按职工号或教学效果综合评分进行排序,并显示;4查找:完成按或课程查找教师的相关记录,并显示;5创建:创建新的纪录,输入数位教师记录,显示在屏幕上并保存;课程设计目的和要求:经过一个学期的C+面向对象实用教程课程的学习,已经有了一定地程序设计基础,但是要学好C+程序设计,不仅要认真阅读课本知识和从事课堂学习,更重要的是要进行上机实践,通过上机实践才能增强和稳固知识。三、系统设计算法分析
2、1、整体结构(1) 整个程序定义四个类CPerson类:包含数据成员nameag§sex,记录,年龄,性别这些信息,并包含构造函数及其他成员函数定义CPerson类以后假设有需要,可再通过继承派生其他类;CTeacher共有继承CPerson类,包含数据成员title,teano,course,score,分别记录职称,职工号,3门课程和教学效果综合评分等信息,另有其他成员函数;CNode类:节点类,包含2个数据成员,CTeacher类对象p和CNode类指针对象next,作为构建链表的单位;CList类:链表类,声明为CNode类的友元类,数据成员有头结点head,尾节点tail,
3、记录当前节点的p和当前节点前一节点的pre,链表相关的输入,显示,排序,查找,创建全部设为成员函数。总体流程为先打开文件,读取文件中的记录来创建链表,然后对链表进行操作,最后保存至文件中3、各函数的功能和实现学院教学信息管理系统的相关功能由对应的函数来实现输入教师信息并显示voidAppend()通过提示一步步输入信息,由程序构建新节点并加入链表显示所有记录voidPrint()3按职工号或教学效果综合评分排序并显示intSortMenu()voidSortMenuControl()voidInsertByTeano(CNode*newp)voidSortByTeano()voidInsert
4、ByScore(CNode*newp)voidSortByScore()4按或课程查找教师记录并显示intSearchMenu()voidSearchMenuControl()voidSearchByName()voidSearchByCourse()四、程序源代码#include"stdafx.h"#include<iostream>#include<fstream>#include<vector>#include<algorithm>#include<cstring>#include<string>
5、usingnamespacestd;classCPersonprivate:stringname;intage;charsex;public:CPerson()(CPerson(stringname,intage=0,charsex='M')(this->name=name;this->age=age;this->sex=sex;voidSetAge(intage=0)(this->age=age;voidSetNameAndSex(stringname,charsex)(this->name=name;this->sex=sex;voidS
6、howInfo()(cout<<name<<"t"<<age<<"t"<<(sex='M'?”男":"女”)<<endl;stringGetName()(returnname;intGetAge()(returnage;charGetSex()(returnsex;classCTeacher:publicCPerson(private:stringtitle;/职称stringteano;/成工号vector<string>course
7、;/散授课程floatscore;/教学效果综合评分public:CTeacher()(CTeacher(stringname,intage=0,charsex='M'):CPerson(name,age,sex)(voidSetData(stringtitle,stringteano)(this->title=title;this->teano=teano;voidSetCourse(stringc1,stringc2,stringc3)(course.push_back(c1);course.push_back(c2);course.push_back(c3);
8、voidSetScore(floatscore)(this->score=score;voidShowInfo()(cout<<teano<<"t"<<GetName()<<"t"<<GetAge()<<"t"<<(GetSex()='M'?"男”:")<<title<<"t"<<course0<<"t"<<co
9、urse1<<"t"<<course2<<"t"<<score<<endl;voidoperator=(CTeacher&one)(CPerson(one.GetName(),one.GetAge(),one.GetSex();this->title=one.title;this->teano=one.teano;this->course0=one.course0;this->course1=one.course1;this->course2=one.cou
10、rse2;this->score=one.score;vector<string>GetCourse()(returncourse;stringGetTitle()(returntitle;stringGetTeano()(returnteano;floatGetScore()(returnscore;classCNode(friendclassCList;private:CTeacherdata;CNode*next;classCList(private:CNode*head;CNode*tail;CNode*p;CNode*pre;intnum;/当前节点数public:
11、intMainMenu()(cout<<”1.显示当前记录"<<endl;cout<<”2.添加记录"<<endl;cout<<"3.排序"<<endl;cout<<"4.查找"<<endl;cout<<"5.创建新纪录"<<endl;cout<<"0.退出"<<endl;cout<<endl;intchoice;cin>>cho
12、ice;returnchoice;voidMainMenuControl()(ReadData();while(1)(intchoice=MainMenu();if(choice=0)break;switch(choice)(case1:Print();break;case2:Append();break;case3:SortMenuControl();break;case4:SearchMenuControl();break;case5:NewList();break;cout<<"是否保存?Y/N:";charc;cin>>c;if(c='
13、;y')Save();voidReadData()(head=tail=newCNode;head->next=NULL;num=0;charfname80;cout<<"请输入要读取的文件:"cin>>fname;ifstreamfile(fname);if(!file)cout<<"出现未知错误导致无法打开!"<<endl;exit(1);stringname,title,teano,course3;intage;charsex;floatscore;while(file.peek()!=
14、EOF)file>>teano>>name>>age>>sex>>title>>course0>>course1>>course2>>score;p=newCNode;p->data.SetNameAndSex(name,sex);p->data.SetAge(age);p->data.SetData(title,teano);p->data.SetCourse(course0,course1,course2);p->data.SetScore(score)
15、;tail->next=p;tail=p;num+;tail->next=NULL;voidPrint()for(p=head->next;p!=NULL;p=p->next)p->data.ShowInfo();cout<<endl;voidAppend()while(1)p=newCNode;cout<<"请输入:"<<endl;cout<<":"stringname;cin>>name;cout<<"年龄:"intage;cin
16、>>age;cout<<"性别F/M:";charsex;cin>>sex;p->data.SetNameAndSex(name,sex);p->data.SetAge(age);cout<<"职称:"stringtitle;cin>>title;cout<<"职工号:"stringteano;cin>>teano;p->data.SetData(title,teano);cout<<"教授课程:"st
17、ringcourse3;cin>>course0>>course1>>course2;p->data.SetCourse(course0,course1,course2);cout<<"教学效果综合评分:"floatscore;cin>>score;p->data.SetScore(score);p->next=tail->next;tail->next=p;tail=p;num+;charc;cout<<"是否继续添加?Y/N:"cin>>
18、c;cin.get();if(c!='y')break;tail->next=NULL;Print();intSortMenu()cout<<"1.按职工号排序"<<endl;cout<<"2.按教学效果综合评分排序"<<endl;cout<<"0.退出"<<endl;cout<<endl;intchoice;cin>>choice;returnchoice;voidSortMenuControl()(while(1)
19、(intchoice=SortMenu();if(choice=0)break;switch(choice)(case1:SortByTeano();break;case2:SortByScore();break;Print();voidInsertByTeano(CNode*newp)(for(pre=head,p=head->next;p!=NULL;pre=p,p=p->next)if(newp->data.GetTeano()<p->data.GetTeano()break;newp->next=p;pre->next=newp;voidSor
20、tByTeano()(p=head->next;head->next=NULL;CNode*nextp;while(p!=NULL)(nextp=p->next;InsertByTeano(p);p=nextp;voidInsertByScore(CNode*newp)(for(pre=head,p=head->next;p!=NULL;pre=p,p=p->next)if(newp->data.GetScore()<p->data.GetScore()break;newp->next=p;pre->next=newp;voidSor
21、tByScore()(p=head->next;head->next=NULL;CNode*nextp;while(p!=NULL)(nextp=p->next;InsertByScore(p);p=nextp;intSearchMenu()(cout<<"1.按查找"<<endl;cout<<"2.按课程查找"<<endl;cout<<"0.退出"<<endl;cout<<endl;intchoice;cin>>choi
22、ce;returnchoice;voidSearchMenuControl()(while(1)(intchoice=SearchMenu();if(choice=0)break;switch(choice)(case1:SearchByName();break;case2:SearchByCourse()break;voidSearchByName()(intn=0;cout<<"请输入:"stringname;cin>>name;for(p=head->next;p!=NULL;p=p->next)if(p->data.GetN
23、ame()=name)(p->data.ShowInfo();n+;if(n=0)cout<<"没有相关记录"<<endl;cout<<endl;voidSearchByCourse()(intn=0;cout<<"请输入查找课程:"stringc;cin>>c;for(p=head->next;p!=NULL;p=p->next)(vector<string>course=p->data.GetCourse();for(inti=0;i<3;i+)if
24、(c=coursei)(p->data.ShowInfo();n+;break;if(n=0)cout<<"没有相关记录"<<endl;cout<<endl;voidNewList()(Destory();head=tail=newCNode;head->next=NULL;while(1)(p=newCNode;cout<<”请输入:"<<endl;cout<<”:"stringname;cin>>name;cout<<"年龄:&quo
25、t;intage;cin>>age;cout<<"性别F/M:";charsex;cin>>sex;p->data.SetNameAndSex(name,sex);p->data.SetAge(age);cout<<"职称:"stringtitle;cin>>title;cout<<"职工号:"stringteano;cin>>teano;p->data.SetData(title,teano);cout<<"教
26、授课程:"stringcourse3;cin>>course0>>course1>>course2;p->data.SetCourse(course0,course1,course2);cout<<"教学效果综合评分:"floatscore;cin>>score;p->data.SetScore(score);tail->next=p;tail=p;num+;cout<<"是否继续输入?Y/N:";charc;cin>>c;cin.get();
27、if(c!='y')break;tail->next=NULL;voidSave()(charfname80;cout<<"保存到:"cin>>fname;ofstreamfile(fname);if(!file)(cout<<"出现未知错误导致无法打开!"<<endl;exit(1);for(p=head->next;p!=NULL;p=p->next)(vector<string>course=p->data.GetCourse();file<&
28、lt;p->data.GetTeano()<<"t"<<p->data.GetName()<<"t"<<p->data.GetAge()<<"t"<<p->data.GetSex()<<"t"<<p->data.GetTitle()<<"t"<<course0<<"t"<<course1<<"t"<<course2<<"t"<<p->data.GetScore()<<endl;file.close();voidDestory()(for(p=head->next;p!=NULL;p=head->next)(head->next=p->next;deletep;deletehead;head=NULL;tail=NULL;pre=NULL;num=0;CList()(
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 三年级下语文教学设计太阳是大家的
- 邵东二中考试试卷及答案
- 山西高二联考试卷及答案
- 三原职教高考试卷及答案
- 2025至2030年中国贵金属清洗机市场分析及竞争策略研究报告
- 硅冶炼原料选择与配料计算考核试卷
- 矿产勘查项目管理流程与效率提升考核试卷
- 经济型酒店品牌竞争策略考核试卷
- 毛皮服装设计与时尚趋势预测考核试卷
- 社会人文与消费者行为考核试卷
- 《特斯拉汽车供应链管理》课件
- 内河船舶船员基本安全知识考试题库300题(含答案)
- 无人机操控 教学设计公开课教案教学设计课件
- 2024 年普通高等学校招生全国统一考试新课标 I 卷-数学试卷-全国
- 《瑞幸咖啡财务造假案例分析》8400字(论文)
- 安全生产法律法规注册安全工程师考试(初级)试题与参考答案(2024年)一
- (试卷)2024贵州省初中学业水平考试·物理
- 云南省职业技能大赛(健康照护赛项)理论参考试题及答案
- 自然辩证法论述题146题带答案(可打印版)
- DB43T 2534-2022 电力气象服务技术规范
- 工程合伙人协议书范文模板下载电子版
评论
0/150
提交评论