C++教师信息管理系统Word文档格式.docx
《C++教师信息管理系统Word文档格式.docx》由会员分享,可在线阅读,更多相关《C++教师信息管理系统Word文档格式.docx(30页珍藏版)》请在冰点文库上搜索。
保
保
结
各函数的功能和实现、3学院教学信息管理系统的相关功能由对应的函数来实现。
(1)输入教师信息并显示
voidAppend()
通过提示一步步输入信息,由程序构建新节点并加入链表
(2)显示所有记录
voidPrint()
(3)按职工号或教学效果综合评分排序并显示
intSortMenu()
voidSortMenuControl()
voidInsertByTeano(CNode*newp)
voidSortByTeano()
voidInsertByScore(CNode*newp)
voidSortByScore()
(4)按姓名或课程查找教师记录并显示
intSearchMenu()
voidSearchMenuControl()
voidSearchByName()
voidSearchByCourse()
四、程序源代码
#includestdafx.h
#include<
iostream>
fstream>
vector>
algorithm>
cstring>
string>
usingnamespacestd;
classCPerson
{
private:
stringname;
intage;
charsex;
public:
CPerson()
{}
CPerson(stringname,intage=0,charsex='
M'
)
this->
name=name;
age=age;
sex=sex;
}
voidSetAge(intage=0)
voidSetNameAndSex(stringname,charsex)
voidShowInfo()
潣瑵?
慮敭?
屜瑜?
愼敧?
?
敳?
尿男?
女)<
<
endl;
stringGetName()
returnname;
intGetAge()
returnage;
charGetSex()
returnsex;
}
};
classCTeacher:
publicCPerson
stringtitle;
//职称
stringteano;
//职工号
vector<
course;
//教授课程
floatscore;
//教学效果综合评分
public:
CTeacher()
CTeacher(stringname,intage=0,char
sex='
):
CPerson(name,age,sex)
voidSetData(stringtitle,stringteano)
{
title=title;
teano=teano;
voidSetCourse(stringc1,stringc2,stringc3)
course.push_back(c1);
course.push_back(c2);
course.push_back(c3);
voidSetScore(floatscore)
score=score;
voidShowInfo()
cout<
teano<
\<
GetName()<
GetAge()<
(GetSex()=='
M?
尿男:
)<
title<
course[0]<
course[1]<
course[2]<
score<
voidoperator=(CTeacher&
one)
CPerson(one.GetName(),one.GetAge(),one.GetSex());
title=one.title;
teano=one.teano;
course[0]=one.course[0];
course[1]=one.course[1];
course[2]=one.course[2];
score=one.score;
GetCourse()
returncourse;
stringGetTitle()
returntitle;
stringGetTeano()
returnteano;
floatGetScore()
returnscore;
classCNode
friendclassCList;
CTeacherdata;
CNode*next;
classCList
CNode*head;
CNode*tail;
CNode*p;
CNode*pre;
intnum;
//当前节点数
intMainMenu()
.显示当前记录<
.添加记录<
.排序<
.查找<
_x0005_.创建新纪录<
退出<
intchoice;
cin>
>
choice;
returnchoice;
voidMainMenuControl()
ReadData();
while
(1)
intchoice=MainMenu();
if(choice==0)break;
switch(choice)
case1:
Print();
break;
case2:
Append();
case3:
SortMenuControl();
case4:
SearchMenuControl();
case5:
NewList();
是否保存?
(Y/N):
;
charc;
c;
if(c=='
y'
)Save();
voidReadData()
head=tail=newCNode;
head->
next=NULL;
num=0;
charfname[80];
请输入要读取的文件:
fname;
ifstreamfile(fname);
if(!
file)
出现未知错误导致无法打开!
exit
(1);
stringname,title,teano,course[3];
intage;
charsex;
while(file.peek()!
=EOF)
file>
teano>
name>
age>
sex>
title>
course[0]>
course[1]>
course[2]>
score;
p=newCNode;
p->
data.SetNameAndSex(name,sex);
data.SetAge(age);
data.SetData(title,teano);
data.SetCourse(course[0],course[1],course[2]);
data.SetScore(score);
tail->
next=p;
tail=p;
num++;
voidPrint()
for(p=head->
next;
p!
=NULL;
p=p->
next)
data.ShowInfo();
voidAppend()
请输入:
姓名:
;
name;
年龄:
age;
性别(F/M):
sex;
职称:
title;
职工号:
teano;
教授课程:
stringcourse[3];
course[2];
教学效果综合评分:
next=tail->
是否继续添加?
(Y/N):
cin.get();
if(c!
='
)break;
tail->
intSortMenu()
.按职工号排序<
.按教学效果综合评分排序<
退出<
voidSortMenuControl()
intchoice=SortMenu();
if(choice==0)break;
SortByTeano();
SortByScore();
Print();
voidInsertByTeano(CNode*newp)
for(pre=head,p=head->
pre=p,p=p->
if(newp->
data.GetTeano()<
data.GetTeano())break;
newp->
pre->
next=newp;
p=head->
head->
CNode*nextp;
while(p!
=NULL)
nextp=p->
InsertByTeano(p);
p=nextp;
voidInsertByScore(CNode*newp)
data.GetScore()<
data.GetScore())break;
newp->
pre->
voidSortByScore()
p=head->
CNode*nextp;
while(p!
nextp=p->
InsertByScore(p);
.按姓名查找<
.按课程查找<
intchoice=SearchMenu();
break;
if(choice==0)
SearchByName();
SearchByCourse();
intn=0;
请输入姓名:
if(p->
data.GetName()==name)
n++;
if(n==0)潣瑵?
没有相关记录<
请输入查找课程:
stringc;
course=p->
data.GetCourse();
for(inti=0;
i<
3;
i++)
if(c==course[i])
没有相关记录<
voidNewList()
Destory();
姓名:
性别(F/M):
职工号:
教授课程:
教学效果综合评分:
是否继续输入?
if(c!
voidSave()
保存到:
ofstreamfile(fname);
出现未知错误导致无法打开!
<
file<
p->
data.GetTeano()<
\
data.GetName()<
data.GetAge()<
data.GetSex()<
data.GetTitle()<
data.GetScore()<
file.close();
voidDestory()
next=p->
deletep;
deletehead;
head=NULL;
tail=NULL;
pre=NULL;
~CList()
intmain(intargc,char*argv[