c学校人员信息管理系统Word格式.docx

上传人:b****2 文档编号:839227 上传时间:2023-04-29 格式:DOCX 页数:29 大小:134.59KB
下载 相关 举报
c学校人员信息管理系统Word格式.docx_第1页
第1页 / 共29页
c学校人员信息管理系统Word格式.docx_第2页
第2页 / 共29页
c学校人员信息管理系统Word格式.docx_第3页
第3页 / 共29页
c学校人员信息管理系统Word格式.docx_第4页
第4页 / 共29页
c学校人员信息管理系统Word格式.docx_第5页
第5页 / 共29页
c学校人员信息管理系统Word格式.docx_第6页
第6页 / 共29页
c学校人员信息管理系统Word格式.docx_第7页
第7页 / 共29页
c学校人员信息管理系统Word格式.docx_第8页
第8页 / 共29页
c学校人员信息管理系统Word格式.docx_第9页
第9页 / 共29页
c学校人员信息管理系统Word格式.docx_第10页
第10页 / 共29页
c学校人员信息管理系统Word格式.docx_第11页
第11页 / 共29页
c学校人员信息管理系统Word格式.docx_第12页
第12页 / 共29页
c学校人员信息管理系统Word格式.docx_第13页
第13页 / 共29页
c学校人员信息管理系统Word格式.docx_第14页
第14页 / 共29页
c学校人员信息管理系统Word格式.docx_第15页
第15页 / 共29页
c学校人员信息管理系统Word格式.docx_第16页
第16页 / 共29页
c学校人员信息管理系统Word格式.docx_第17页
第17页 / 共29页
c学校人员信息管理系统Word格式.docx_第18页
第18页 / 共29页
c学校人员信息管理系统Word格式.docx_第19页
第19页 / 共29页
c学校人员信息管理系统Word格式.docx_第20页
第20页 / 共29页
亲,该文档总共29页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

c学校人员信息管理系统Word格式.docx

《c学校人员信息管理系统Word格式.docx》由会员分享,可在线阅读,更多相关《c学校人员信息管理系统Word格式.docx(29页珍藏版)》请在冰点文库上搜索。

c学校人员信息管理系统Word格式.docx

//只提供名字查询(其他以后加入)

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

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)

intcom;

com=compareStr(nm,p->

name);

com<

while(p->

next&

com>

0)//比p节点小或者p为空退出

p=p->

com=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);

if(p-

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

当前位置:首页 > 党团工作 > 入党转正申请

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2