c++学校人员信息管理系统Word下载.docx
- 文档编号:21672312
- 上传时间:2023-01-31
- 格式:DOCX
- 页数:24
- 大小:134.24KB
c++学校人员信息管理系统Word下载.docx
《c++学校人员信息管理系统Word下载.docx》由会员分享,可在线阅读,更多相关《c++学校人员信息管理系统Word下载.docx(24页珍藏版)》请在冰豆网上搜索。
//只提供名字查询(其他以后加入)
//返回前一个节点的指针
voidorderList(chainList*list);
//按名字排序
voidorderListByAge(chainList*list);
//按年龄降序排列
voidorderListBySex(chainList*list);
//按照性别排列,女士优先
voidprintStaticInfo(chainList*list);
voidprintList(chainList*list);
intmain()
{cout<
<
"
\tYouarewelcometothemanagementsystem!
endl;
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:
\t1.Addaperson.2.Deleteaperson3.Editaperson"
\t4.Searchaperson5.Orderthelist6.Printinfoaboutthelist"
\t0.exit"
ctn;
switch(ctn)
{
case'
0'
:
break;
1'
addList(head);
break;
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{
Thepersonsinforfollows:
pdel->
next->
pl->
print();
Areyousuretodeleteit?
Pressyorn"
cin>
sure;
if(sure=='
y'
{
deleteNode(pdel);
cout<
nm<
havebeendeleted!
}
3'
charnm1[20];
nm1;
chainList*pp;
pp=searchList(head,nm1);
if(pp->
Theperson'
sinforfollows:
pp->
Now,pleaseedittheinfors."
editList(head,nm1);
else
Thepersoncan'
tbefound!
!
4'
charname[30];
name;
chainList*p;
p=searchList(head,name);
if(p->
p->
tbefound!
5'
Youwanttoorderthelistby:
1.name2.age3.sex(ladyfirst)"
charch;
ch;
switch(ch)
case'
Youchoosetoorderthelistbyname.Theresultareasfollows:
orderList(head);
printStaticInfo(head);
break;
Youchoosetoorderthelistbyage.Theresultareasfollows:
orderListByAge(head);
Youchoosetoorderthelistbysex.Theresultareasfollows:
orderListBySex(head);
default:
Wrongchoice!
6'
printStaticInfo(head);
default:
}while(ctn!
='
);
Doyouwanttosavethefile?
No,pressn.Else,anyotherkey."
charsave;
save;
if(save!
{
Pleaseinputthefile'
ofstreamfin;
fin.open(fileName);
//如果文件已经存在,询问是否覆盖。
如何知道是否存在
if(!
fin)
Can'
topenoutputfile.\n"
fileWrite(head,fin);
fin.close();
Filehasbeensuccessfullysaved!
Byebye!
return0;
}
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>
sx;
switch(tp)
case1:
grd;
schl;
psn=newstudent(ag,nm,sx,grd,schl,e,m,g,average);
case2:
sb;
teaYear;
psn=newteacher(ag,nm,sx,sb,teaYear);
case3:
slr;
psn=newempoyee(ag,nm,sx,slr);
chainList*s=newchainList(tp,psn);
next=s;
p=s;
chainList*p=list->
next;
while(p)
ff<
p->
typeOfPn<
"
age<
name<
sex<
switch(p->
typeOfPn)
ff<
((student*)p->
pl)->
grade<
school<
((teacher*)p->
subject<
yearsOfT<
((empoyee*)p->
salary<
p=p->
intaa=0;
ff<
aa;
intcompareStr(char*str1,char*str2)//比较字符串
char*p1=str1,*p2=str2;
inti=0;
while((p1[i]==p2[i])&
&
p1[i]&
p2[i])
i++;
if(p1[i]==p2[i])
return0;
else
{if(p1[i]>
else
return-1;
}
voidaddList(chainList*list)//添加节点
chartp;
inttype;
do{
Thepersonwhoseinfoyouwanttoinputis:
1.astudent2.ateacher3.acommonemployee"
0.Returntomainmenu."
//为什么一输入字符就死循环?
?
intg;
switch(tp)
aa=0;
type=0;
type=1;
name:
age:
maleorfemale?
morf?
Thestudent'
sgrade"
Fromwhichschool:
thescoreofenglish:
e;
thescoreofmath:
m;
thescoreofsjjg:
g;
average:
average<
type=2;
subjectfield:
Yearsasateacher:
type=3;
Theemployee'
ssalary:
type=6;
aa=0;
chainList*p=list;
//新节点在p所指的节点之前插入,
if(aa)
int;
=compareStr(nm,p->
name);
while(p->
next&
0)//比p节点小或者p为空退出
p=p->
=compareStr(nm,p->
chainList*s=newchainList(type,psn);
s->
next=p->
}
}while(type);
voiddeleteNode(chainList*node)
chainList*ptemp=node->
node->
next=ptemp->
deleteptemp;
voideditList(chainList*list,char*name)//删除,添加就是编辑。
缺点:
不想删除的也被删除了。
chainList*pde;
pde=searchList(list,name);
inte;
intm;
if(tp==1||tp==2||tp==3)
deleteNode(pde);
=comp
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- c+ 学校 人员 信息管理 系统
![提示](https://static.bdocx.com/images/bang_tan.gif)