数据结构课程设计报告简单的职工管理系统Word格式.docx
- 文档编号:17639350
- 上传时间:2022-12-07
- 格式:DOCX
- 页数:20
- 大小:424.49KB
数据结构课程设计报告简单的职工管理系统Word格式.docx
《数据结构课程设计报告简单的职工管理系统Word格式.docx》由会员分享,可在线阅读,更多相关《数据结构课程设计报告简单的职工管理系统Word格式.docx(20页珍藏版)》请在冰豆网上搜索。
char*address;
char*phone;
structWorker*next;
}worker;
2.主体函数
(1).输入函数
voidScanfwork(worker**phead,worker**pend,intnum);
(2).输出函数
voidPrintfwork(worker*phead);
(3).查询职工函数
voidFindworker(worker*phead);
(4).更新职工函数
voidUpdata(worker*phead);
(5).删除职工函数
voidDelwork(worker**phead,worker**pend);
voidDelete(worker**phead,worker**pend,char*name);
(6).按字典排序函数
worker*Sort(worker**phead,worker**pend,intnum);
(7).文件调用函数
voidsave(worker*phead);
(8).增加职工函数
voidAddworker(worker**phead,worker**pend,worker*p);
worker*GetnodeIn();
3.详细设计
1.流程图
2.代码详细分析
(1).输入函数
voidScanfwork(worker**phead,worker**pend,intnum)
{
inti;
srand((unsignedint)time(0));
for(i=0;
i<
num;
i++)
{
Addworker(phead,pend,Getwork());
}
}
voidPrintfwork(worker*phead)
while(phead)
printf("
%s%s%s%s%s%s%s%s\n"
phead->
name,phead->
sex,phead->
Bothdate,phead->
Workdate,phead->
school,phead->
duty,phead->
phone,phead->
address);
phead=phead->
next;
}
printf("
b返回主菜单"
);
key=getchar();
switch(key)
case'
b'
:
return;
break;
default:
按错了\n"
voidFindworker(worker*phead)
char*keyword=NULL;
worker*w=NULL;
worker*newhead=NULL;
worker*newend=NULL;
worker*pDel=NULL;
worker*bj=phead;
while
(1)
while
(1)
{
printf("
请输入要查询的关键字:
keyword=getstring();
按a键确认你的输入,按其他键重新输入:
if(getkey()=='
a'
)
break;
else
free(keyword);
keyword=NULL;
}
phead=bj;
while(phead)
if(strncmp(phead->
name,keyword,strlen(keyword))==0||
strncmp(phead->
sex,keyword,strlen(keyword))==0||
Bothdate,keyword,strlen(keyword))==0||
Workdate,keyword,strlen(keyword))==0||
school,keyword,strlen(keyword))==0||
duty,keyword,strlen(keyword))==0||
address,keyword,strlen(keyword))==0||
phone,keyword,strlen(keyword))==0)
w=(worker*)malloc(sizeof(worker));
w->
name=phead->
name;
sex=phead->
sex;
Bothdate=phead->
Bothdate;
Workdate=phead->
Workdate;
duty=phead->
duty;
school=phead->
school;
address=phead->
address;
phone=phead->
phone;
next=NULL;
Addworker(&
newhead,&
newend,w);
phead=phead->
if(newhead!
=NULL)
Printfwork(newhead);
while(newhead)
pDel=newhead;
newhead=newhead->
free(pDel);
pDel=NULL;
newhead=NULL;
newend=NULL;
if(key=='
return;
else
没有找到\n"
voidUpdata(worker*phead)
char*name1;
请输入要修改的名字"
name1=getstring();
phead=bj;
if(strncmp(phead->
name,name1,strlen(name1))==0)
请输入新的"
free(phead->
phone);
phead->
phone=getstring();
y继续修改,其他键返回"
if(getkey()!
='
y'
voidDelwork(worker**phead,worker**pend)
请输入删除的:
name1=getstring();
Delete(phead,pend,name1);
按y继续删除其他键返回主菜单\n"
if(getkey()!
voidDelete(worker**phead,worker**pend,char*name)
worker*bj=*phead;
if(strncmp((*phead)->
pDel=*phead;
*phead=(*phead)->
free(pDel);
pDel=NULL;
while(bj->
next!
if(strncmp(bj->
next->
pDel=bj->
bj->
next=bj->
free(pDel);
pDel=NULL;
if(bj->
next==NULL)
*pend=bj;
bj=bj->
worker*Sort(worker**phead,worker**pend,intnum)
inti;
intj;
worker*bj=*phead;
worker*sign=NULL;
worker*sign1=NULL;
chartemp[20]={0};
chartemp1[20]={0};
chartemp2[20]={0};
chartemp3[20]={0};
chartemp4[20]={0};
chartemp5[20]={0};
chartemp6[15]={0};
chartemp7[12]={0};
for(i=0;
bj=(*phead);
sign=bj;
for(j=i+1;
j<
j++)
sign1=sign->
if(strncmp(sign->
name,sign1->
name,strlen(sign1->
name))>
=0)
strcpy(temp,sign->
name);
strcpy(temp1,sign->
sex);
strcpy(temp2,sign->
Bothdate);
strcpy(temp3,sign->
Workdate);
strcpy(temp4,sign->
school);
strcpy(temp5,sign->
duty);
strcpy(temp6,sign->
strcpy(temp7,sign->
strcpy(sign->
sex,sign1->
Bothdate,sign1->
Workdate,sign1->
school,sign1->
duty,sign1->
address,sign1->
phone,sign1->
strcpy(sign1->
name,temp);
sex,temp1);
Bothdate,temp2);
Workdate,temp3);
school,temp4);
duty,temp5);
address,temp6);
phone,temp7);
sign=sign->
return*phead;
voidsave(worker*phead)
FILE*pf;
fopen_s(&
pf,"
F:
\\worker.txt"
"
w+"
fprintf(pf,"
fclose(pf);
(9).增加职工函数
voidAddworker(worker**phead,worker**pend,worker*p)
if(*phead==NULL)
*phead=p;
else
(*pend)->
next=p;
*pend=p;
worker*GetnodeIn()
worker*w=(worker*)malloc(sizeof(worker));
请输入名字\n"
w->
name=getstring();
请输入性别\n"
sex=getstring();
请输入出生年月\n"
Bothdate=getstring();
请输入工作年月\n"
Workdate=getstring();
请输入学历\n"
school=getstring();
请输入职务\n"
duty=getstring();
请输入\n"
请输入住址\n"
address=getstring();
returnw;
4.调试分析
1.在写职工程序的时候遇到了单链表排序问题,解决的方法我选择了询问网络以及身边的朋友
2.当写删除的时候遇到了头删除的问题,解决方法我选择了查看书籍
3.当调用文件保存的时候也遇到了问题,例如文件容不能直接覆盖,数据不能全部输出等问题,解决的方法我选择了询问网络,查看视频等
4.在写职工程序的时候,虽然遇到了很多问题,我通过自己的努力以及身边朋友的帮助,使我克服了问题,这次的课程设计提高我自己写代码能力,以及训练了我运用链表的增删改查方面的知识和文件的调用存取方面的知识。
5.用户使用说明
(1).可以直接运行程序,当运行程序后,会有五个选项
(2).可以通过选择序号来完成自已有想要做的事情
(3).数据会自动的存在文本文档,可以直接选择查看
(4).q可以直接退出程序
6.测试结果
(1).菜单测试结果
(2).查看职工测试结果
(3).添加职工测试结果
(4).查询职工测试结果
(5).修改职工测试结果
(6).删除职工测试结果
附录:
#include<
stdio.h>
stdlib.h>
time.h>
string.h>
charkey;
intG_key;
typedefstructWorker
worker*Getwork();
char*Getname();
char*Getsex();
char*GetBothdate();
char*GetWorkdate();
char*Getschool();
char*Getduty();
char*Getaddress();
char*Getphone();
chargetkey();
char*getstring();
voidScanfwork(worker**phead,worker**pend,intnum);
intmain()
worker*phead=NULL;
worker*pend=NULL;
worker*bj=NULL;
charc;
G_key=12;
Scanfwork(&
phead,&
pend,G_key);
bj=phead;
1.查看职工信息\n"
2.添加职工信息\n"
3.查询职工信息\n"
4.修改职工信息\n"
5.删除职工信息\n"
q.退出\n"
c=getkey();
switch(c)
case'
1'
Printfwork(Sort(&
pend,G_key));
save(Sort(&
break;
2'
Addworker(&
pend,GetnodeIn());
G_key+=1;
3'
Findworker(phead);
4'
Updata(phead);
5'
Delwork(&
pend);
G_key-=1;
q'
return0;
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数据结构 课程设计 报告 简单 职工 管理 系统
![提示](https://static.bdocx.com/images/bang_tan.gif)