c++学校人员信息管理系统.docx

上传人:b****2 文档编号:396796 上传时间:2022-10-09 格式:DOCX 页数:26 大小:130.29KB
下载 相关 举报
c++学校人员信息管理系统.docx_第1页
第1页 / 共26页
c++学校人员信息管理系统.docx_第2页
第2页 / 共26页
c++学校人员信息管理系统.docx_第3页
第3页 / 共26页
c++学校人员信息管理系统.docx_第4页
第4页 / 共26页
c++学校人员信息管理系统.docx_第5页
第5页 / 共26页
点击查看更多>>
下载资源
资源描述

c++学校人员信息管理系统.docx

《c++学校人员信息管理系统.docx》由会员分享,可在线阅读,更多相关《c++学校人员信息管理系统.docx(26页珍藏版)》请在冰豆网上搜索。

c++学校人员信息管理系统.docx

c++学校人员信息管理系统

 

1.C++课程设计题目:

《学校人员信息管理系统》

用c++设计一个大学教师和学生管理程序,教师包括编号(a),(c),职称(d)和教研室数据(b)的数据输入输出;大学生包括编号(m),(s),性别(t),班号(n),英语(e),高等数学(f)和数据结构(g)三门课程成绩输入输出和计算机平均分(ave);研究生包括编号,,性别,班号,指导教师和研究方法数据输入输出;博士后数据的输入输出;博士后既是教师也是研究生.(用派生,继承的方法可以做)

2.功能如下图所示:

3.部分代码

#include

#include

#include"persons.h"

#include"student.h"

#include"teacher.h"

#include"empoyee.h"

#include"chainList.h"

#include

voidfileRead(chainList*list,ifstream&ff);//把文件从硬盘上读入存

voidfileWrite(chainList*list,ofstream&ff);//写入硬盘

intcompareStr(char*str1,char*str2);//名字作为关键字,这个函数就用来比较

voidaddList(chainList*list);//同名的话,覆盖,或者改为新名字加入

voiddeleteNode(chainList*node);//根据名字删除

voideditList(chainList*list,char*name);//要编辑的人名和新的资料

chainList*searchList(chainList*list,char*name);//只提供名字查询(其他以后加入)

//返回前一个节点的指针

voidorderList(chainList*list);//按名字排序

voidorderListByAge(chainList*list);//按年龄降序排列

voidorderListBySex(chainList*list);//按照性别排列,女士优先

voidprintStaticInfo(chainList*list);

voidprintList(chainList*list);

intmain()

{cout<<"\tYouarewelcometothemanagementsystem!

"<

cout<<"Doyouwanttoloadafileorsetupanewlist?

Presslors."<

charsn;

cin>>sn;

charfileName[30];

chainListheadNode(0,NULL);

chainList*head=&headNode;

if(sn=='l')

{ifstreamfile;

cout<<"File'sname:

"<

cin>>fileName;

file.open(fileName);

if(!

file)//为何输入不存在地文件后,机子变得很慢,而且没有结果出来?

{cout<<"Filenotfound!

Systemexit."<

return1;

}

//cout<<"test"<

file的检查?

(文件不存在阿)

fileRead(head,file);//读入文件到链表

file.close();

}

printStaticInfo(head);

charctn;

do

{cout<<"mainmenu:

"<

cout<<"\t1.Addaperson.2.Deleteaperson3.Editaperson"<

cout<<"\t4.Searchaperson5.Orderthelist6.Printinfoaboutthelist"<

cout<<"\t0.exit"<

cin>>ctn;

switch(ctn)

{

case'0':

break;

case'1':

addList(head);

break;

case'2':

cout<<"Pleaseinputtheperson'snametobedeleted:

"<

charnm[20];

cin>>nm;

chainList*pdel;

pdel=searchList(head,nm);

charsure;//Makesurewhetheryouwanttodeletethedata

sure='n';

if(!

pdel->next)

{

cout<<"Thepersonyouinputcann'tbefound"<

}

else{

cout<<"Thepersonsinforfollows:

"<

pdel->next->pl->print();

cout<<"Areyousuretodeleteit?

Pressyorn"<

cin>>sure;

if(sure=='y')

{

deleteNode(pdel);

cout<

"<

}

}

break;

case'3':

cout<<"Pleaseinputtheperson'sname:

"<

charnm1[20];

cin>>nm1;

chainList*pp;

pp=searchList(head,nm1);

if(pp->next)

{

cout<<"Theperson'sinforfollows:

"<

pp->next->pl->print();

cout<<"Now,pleaseedittheinfors."<

editList(head,nm1);

}

else

cout<<"Thepersoncan'tbefound!

!

"<

break;

case'4':

cout<<"Pleaseinputtheperson'sname:

"<

charname[30];

cin>>name;

chainList*p;

p=searchList(head,name);

if(p->next)

{

p->next->pl->print();

}

else

cout<<"Thepersoncan'tbefound!

"<

break;

case'5':

cout<<"Youwanttoorderthelistby:

"<

cout<<"1.name2.age3.sex(ladyfirst)"<

charch;

cin>>ch;

switch(ch)

{

case'1':

cout<<"Youchoosetoorderthelistbyname.Theresultareasfollows:

"<

orderList(head);

printStaticInfo(head);

break;

case'2':

cout<<"Youchoosetoorderthelistbyage.Theresultareasfollows:

"<

orderListByAge(head);

printStaticInfo(head);

break;

case'3':

cout<<"Youchoosetoorderthelistbysex.Theresultareasfollows:

"<

orderListBySex(head);

printStaticInfo(head);

break;

default:

cout<<"Wrongchoice!

"<

}

break;

case'6':

printStaticInfo(head);

break;

default:

cout<<"Wrongchoice!

"<

}

}while(ctn!

='0');

cout<<"Doyouwanttosavethefile?

No,pressn.Else,anyotherkey."<

charsave;

cin>>save;

if(save!

='n')

{

cout<<"Pleaseinputthefile'sname:

"<

cin>>fileName;

ofstreamfin;

fin.open(fileName);//如果文件已经存在,询问是否覆盖。

如何知道是否存在

if(!

fin)

{

cout<<"Can'topenoutputfile.\n";

return1;

}

fileWrite(head,fin);

fin.close();

cout<<"Filehasbeensuccessfullysaved!

"<

}

cout<<"Byebye!

"<

return0;

}

voidfileRead(chainList*list,ifstream&ff)

{

chainList*p=list;

inttp;

charnm[20];

intag;

charsx;

intslr;

intgrd;

inte;

intm;

intg;

intaverage;

charschl[20];

charsb[20];

intteaYear;

intaa=1;

persons*psn;//插入人员指针

ff>>tp;

while(tp)

{ff>>ag;

ff>>nm;

ff>>sx;

switch(tp)

{

case1:

ff>>grd;

ff>>schl;

psn=newstudent(ag,nm,sx,grd,schl,e,m,g,average);

b

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 解决方案 > 学习计划

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1