


版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、课程设计问题描述学院教学信息管理系统是高等学校教务管理的重要组成局部,其内容较多, 为了简化计论,要求设计的管理系统能够完成以下功能: 1输入:输入每一位教师记录,将其信息写入文件中; 2显示:显示每位教师记录; 3排序:按职工号或教学效果综合评分进行排序,并显示; 4查找:完成按或课程查找教师的相关记录,并显示; 5创立:创立新的纪录,输入数位教师记录,显示在屏幕上并保存;课程设计目的和要求:经过一个学期的?C+面向对象实用教程?课程的学习,已经有了一定地程 序设计根底,但是要学好C+程序设计,不仅要认真阅读课本知识和从事课堂学 习,更重要的是要进行上机实践,通过上机实践才能增强和稳固知识。
2、三、系统设计算法分析1、 整体结构整个程序定义四个类1CPerson类:包含数据成员name age sex,记录,年龄,性别这些信息, 并包含构造函数及其他成员函数 定义CPerson类以后假设有需要,可再 通过继承派生其他类;2CTeache:共有继承 CPerson 类,包含数据成员 title , tea no, course, score, 分别记录职称,职工号, 3 门课程和教学效果综合评分等信息,另有其他 成员函数;3 CNode类:节点类,包含2个数据成员,CTeacher类对象p和CNode类 指针对象next,作为构建链表的单位;4 CList类:链表类,声明为CNode类
3、的友元类,数据成员有头结点 head, 尾节点tail,记录当前节点的p和当前节点前一节点的pre,链表相关的输 入,显示,排序,查找,创立全部设为成员函数。总体流程为先翻开文件,读取文件中的记录来创立链表,然后对链表进行操作, 最后保存至文件中学习文档仅供参考3、 各函数的功能和实现学院教学信息管理系统的相关功能由对应的函数来实现 ( 1) 输入教师信息并显示 void Append() 通过提示一步步输入信息,由程序构建新节点并参加链表( 2) 显示所有记录 void Print()3按职工号或教学效果综合评分排序并显示 int SortMenu() void SortMenuContro
4、l()void InsertByTeano(CNode *newp)void SortByTeano()void InsertByScore(CNode *newp)void SortByScore()4按或课程查找教师记录并显示int SearchMenu() void SearchMenuControl() void SearchByName() void SearchByCourse()四、程序源代码#include stdafx.h #include #include #include #include #include #include using namespace std;cla
5、ss CPersonprivate:string name; int age; char sex;public:CPerson()CPerson(string name,int age=0,char sex=M) this-name=name; this-age=age; this-sex=sex;void SetAge(int age=0) this-age=age;void SetNameAndSex(string name,char sex) this-name=name; this-sex=sex;void ShowInfo()coutnamevtvvagevvtvv(sex=M?男:
6、女) course;/教 授课程float score;/教学效果综合评分public:CTeacher()CTeacher(string name,int age=0,char sex=M):CPerson(name,age,sex)void SetData(string title,string teano)this-title=title; this-teano=teano;void SetCourse(string c1,string c2,string c3)course.push_back(c1);course.push_back(c2);course.push_back(c3);
7、void SetScore(float score)this-score=score;void ShowInfo()coutteanotGetName()tGetAge()t(GetSex()=M? 男 :)titletcourse0tcourse1tcourse2tscoretitle=one.title;this-teano=one.teano;this-course0=one.course0;this-course1=one.course1;this-course2=one.course2;this-score=one.score;vector GetCourse()return cou
8、rse;string GetTitle()return title;string GetTeano()return teano;float GetScore()return score;class CNodefriend class CList;private:CTeacher data;CNode *next;class CListprivate:CNode *head;CNode *tail;CNode *p;CNode *pre;int nu m;当前节点数public:int MainMenu()cout1.显示当前记录endl; cout2.添加记录endl; cout3.排序e n
9、dl; cout4.查找e ndl;cout5.创立新纪录endl; cout0.退出e ndl; coutchoice;return choice;void MainMenuControl()ReadData();while ( 1 )int choice=MainMenu();if ( choice=0 ) break;switch ( choice )case 1:Print();break;case 2:Append();break;case 3:SortMenuControl();break;case 4:SearchMenuControl(); break;case 5:NewLi
10、st();break;coutvv是否保存? Y/N :;char c;cinc;if ( c=y ) Save();void ReadData()head=tail=new CNode; head-next=NULL; num=0; char fname80;coutvv请输入要读取的文件:;cinfname; ifstream file(fname); if ( !file ) coutvv出现未知错误导致无法翻开!teanonameagesextitlecourse0course1course2scop=new CNode;p-data.SetNameAndSex(name,sex);p
11、-data.SetAge(age);p-data.SetData(title,teano);p-data.SetCourse(course0,course1,course2);p-data.SetScore(score);tail-next=p;tail=p;num+;tail-next=NULL;void Print()for ( p=head-next; p!=NULL; p=p-next)p-data.ShowInfo();coutvvendl;void Append()while ( 1 )p=new CNode;cout请输入:endl;coutname;coutvv年龄:;int
12、age;cinage;coutvv性别F/M:;char sex;cinsex;p-data.SetNameAndSex(name,sex); p-data.SetAge(age);coutvv职称:;string title;cintitle;coutvv职工号:;string teano;cinteano;p-data.SetData(title,teano);coutvv教授课程:;string course3; cincourse0course1course2; p-data.SetCourse(course0,course1,course2); coutvv教学效果综合评分:;flo
13、at score;cinscore;p-data.SetScore(score); p-next=tail-next;tail-next=p;tail=p;num+;Y/N: char c;coutvv是否继续添加?cinc;cin.get();if ( c!=y ) break;tail-next=NULL;Print();int SortMenu() coutvv1.按职工号排序endl;cout2.按教学效果综合评分排序endl;cout0.退出e ndl;coutchoice;return choice;void SortMenuControl()while ( 1 )int choi
14、ce=SortMenu();if ( choice=0 ) break; switch ( choice )case 1:SortByTeano(); break;case 2:SortByScore(); break; Print();void InsertByTeano(CNode *newp)for ( pre=head,p=head-next; p!=NULL; pre=p,p=p-next) if ( newp-data.GetTeano() data.GetTeano() )break; newp-next=p;pre-next=newp;void SortByTeano() p=
15、head-next; head-next=NULL;CNode *nextp;while ( p!=NULL )nextp=p-next;InsertByTeano(p);p=nextp;void InsertByScore(CNode *newp)for ( pre=head,p=head-next; p!=NULL; pre=p,p=p-next) if ( newp-data.GetScore() data.GetScore() ) break;newp-next=p;pre-next=newp;void SortByScore()p=head-next;head-next=NULL;C
16、Node *nextp;while ( p!=NULL )nextp=p-next;InsertByScore(p);p=nextp;int SearchMenu()cout1.按查找e ndl;cout2.按课程查找endl;cout0.退出e ndl;coutchoice;return choice;void SearchMenuControl()while ( 1 )int choice=SearchMenu();if ( choice=0 ) break;switch ( choice )case 1:SearchByName(); break;case 2:SearchByCours
17、e()b;reak;void SearchByName()int n=0;coutname;for ( p=head-next; p!=NULL; p=p-next) if ( p-data.GetName()=name ) p-data.ShowInfo();n+;if ( n=0 ) cout没有相关记录endl; coutc;for ( p=head-next; p!=NULL; p=p-next)vector course=p-data.GetCourse(); for (int i=0; idata.ShowInfo(); n+; break;if ( n=0 ) cout没有相关记
18、录endl; coutnext=NULL;while ( 1 ) p=new CNode;cout请输入:endl; coutname;coutvv年龄:;int age; cinage;coutvv性别F/M:;char sex; cinsex; p-data.SetNameAndSex(name,sex); p-data.SetAge(age);coutvv职称:; string title; cintitle;coutvv职工号:; string teano; cinteano;p-data.SetData(title,teano);coutvv教授课程:; string course3
19、; cincourse0course1course2;p-data.SetCourse(course0,course1,course2); coutvv教学效果综合评分:;float score; cinscore;p-data.SetScore(score); tail-next=p;tail=p;num+;coutvv是否继续输入? Y/N:; char c;cinc; cin.get();if ( c!=y ) break; tail-next=NULL;void Save()char fname80;coutfname;ofstream file(fname);if ( !file )
20、coutvv出现未知错误导致无法翻开!next; p!=NULL; p=p-next)vector course=p-data.GetCourse();filedata.GetTeano()tdata.GetName()tdata.GetAge()tdata.GetSex()t data.GetTitle()t course0tcourse1tcourse2t data.GetScore()next; p!=NULL; p=head-next)head-next=p-next;delete p;delete head;head=NULL;tail=NULL;pre=NULL;num=0;CList()for ( p=head-next; p!=NULL; p=head-next)head-next=p-next;delete p;delete head; head=NULL; tail=NULL; pre=NULL;int main (i nt argc, cha
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 中外陶瓷商务英语知到课后答案智慧树章节测试答案2025年春景德镇陶瓷大学
- 河北省邢台市育才中学人教版高中物理必修一33摩擦力学案
- 山东省平邑县曾子学校高中生物必修二学案第三章基因的本质第1节DNA是主要的遗传物质(学案16)
- 山西省长治运城大同朔州阳泉五地市高三上学期期末联考理综生物试题
- 人教版高中化学选修四2-3-3化学平衡常数课时练习2
- 2017-2018学年化学苏教必修2讲义专题3有机化合物的获得与应用第2单元第1课时
- 基于ANSYS的双梁桥式起重机小车轻量化研究
- 农村区域发展现状及农业推广策略研究
- 水稻与小龙虾共作模式初探
- 人防施工组织设计
- 卵巢癌的健康宣教
- DB45T 2758-2023 小型水利工程施工质量管理与评定规范
- 中建测评二测题库
- 店长管理员工培训
- DB11∕T 3010-2018 冷链物流冷库技术规范
- 爱普生L4168说明书
- 现代家政导论-课件 2.2家庭制度认知
- 题型专训:平方差公式和完全平方公式
- 内容审核机制
- 公司解散清算的法律意见书、债权处理法律意见书
- 《网络营销》试题及答案2
评论
0/150
提交评论