数据结构课程设计_员工信息管理系统方案.doc

上传人:scccc 文档编号:13427920 上传时间:2021-12-25 格式:DOC 页数:22 大小:389KB
返回 下载 相关 举报
数据结构课程设计_员工信息管理系统方案.doc_第1页
第1页 / 共22页
数据结构课程设计_员工信息管理系统方案.doc_第2页
第2页 / 共22页
数据结构课程设计_员工信息管理系统方案.doc_第3页
第3页 / 共22页
亲,该文档总共22页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《数据结构课程设计_员工信息管理系统方案.doc》由会员分享,可在线阅读,更多相关《数据结构课程设计_员工信息管理系统方案.doc(22页珍藏版)》请在三一文库上搜索。

1、成绩12信计 2013-2014 (一)数据结构课程设计设计题目员工信息管理系统设计时间2014.1.62014.1.10学生姓名葛考学生学号20120402127所在班级12精算指导教师刘风华徐州工程学院数学与物理科学学院题目员工信息管理系统需求分析员工信息管理系统设计,具体功能如下:1、系统以菜单方式工作,应为用户提供清晰的使用提示,依据用户的选择来进行各种处 理,并且在此过程中能够尽可能的兼容用户使用过程中的输入异常情况。2、员工信息录入系统(员工信息用文件保存),注意员工按员工编号进行区分,即每个 员工的员工编号都是唯一的,不允许出现两个员工或员工编号相同的情况。3、可对员工信息进行查

2、询,具体分为:按姓名查询、按员工号查询、按生日查询;4、可对员工信息进行删除;5、可对员工信息进行修改,但应注意员工号不能修改,修改应逐个进行,一个员工记录 的更改不应影响其他的员工记录;6可对全部的员工信息进行显示 v (员工信息浏览),注意员工信息的显示规范; 员工信息应包括姓名、员工编号、性别、年龄、生日、学历、职务、联系电话、住 址。二、概要设计2.1、抽象数据类型ADT List数据对象:D=ai|ai ElemSet,i=1,2,n,n>=0数据关系:R仁<ai-1,ai>|ai-1 ,ai D, i=1,2,n基本操作:Init List(&L);操作结

3、果:构造一个空的线性表L。DestroyList(&L);初始条件:线性表L存在。 操作结果:销毁线性表L。LocateElem(L,l,&e);初始条件:线性表L存在,1<i<Listlength(L)。操作结果:用e返回线性表L中第i个数据元素的值。ClearList(&L);初始条件:线性表L存在。操作结果:将线性表L重置为空表。ADT Graph2.2、程序流程系统的执行从菜单的选择开始,依据用户的选择进行相应的处理,直到用户选择退 出系统为止。其间应对用户的选择做出判断及异常处理。系统的流程如图1所示:图1员工信息管理系统流程图三、详细设计3.1函

4、数构成(1)主函数:void ma in ();(2)文件读入函数:void read data ();(3)文件写入函数:void write data ();(4)菜单函数函数原型:void Menu ()功能:此函数的功能为依据用户选择的功能来进行相应的处理,直到用户选择退出 系统为止,包括员工信息的查询、更新、列表及退出管理;(5)信息查询函数函数原型:void chaxun ()功能:该函数的功能是按照用户的选择进行不同方式的查找,本程序实现了按三种 方式进行查找,包括按编号、姓名、生日查找;(6)信息更新函数函数原型:void gengxin ()功能:此函数的功能为使用户修改记录

5、。首先判断用户要修改的记录是否存在,因 为只有员工编号是唯一的,所以根据员工编号进行查找。若存在则用用户输入的新的信 息替换原信息;若不存在则函数结束。在此函数中要注意的是文件的打开方式应 为” rb+”,因为在这个函数中不仅要读文件,还要向文件中写入数据,所以要用读写的 方式打开二进制文件;(7)信息一览函数函数原型:void liebiao ()功能:此函数的功能为从文件中依次取出每条记录并将其显示出来。因为只需读文 件不需要向文件中写入数据,所以文件的打开方式是只读。3.2模块程序清单(详细程序见附录)1、员工信息的结构体:Typedef struct emp long int num;

6、/编号char n ame20;/姓名int age;/年龄char sex4;/性别char birthday10;/生日char tel15;/电话char edu8;/学历char pos20;/职务char add30;/住址struct emp *n ext;2、菜单函数:void menu( void) char i,lj100;int flog;time_t T;struct tm * time now;time ( &T );time now = localtime ( &T);flog=0;while(1) system("cls"); p

7、rintf("lprin tf("|prin tf("|prin tf("|prin tf("|prin tf("|prin tf("|print f("|prin tf("|prin tf("|prin tf("|prin tf("|prin tf("|prin tf("|prin tf("|prin tf("|prin tf("|prin tf("|prin tf("|prin tf("|pr

8、intf("L-prin tf("nnnnn");员工信息管理系统1.员工信息查询2.员工信息更新3.员工信息列表0.退出管理系统n"); I n"); I n"); I n"); I n"); I n"); I n"); I n"); I n"); I n"); I n"); I n"); I n"); I n"); I n"); I n"); I n"); I n"); I n&qu

9、ot;); I n");n");prin tf(" %s", asctime (time now); printf("请输入您的选择(数字0-3): n");sca nf("%c",&i);gets(lj);if(lj0)i='a'switch(i) case '1':chax un() ;break;case '2':ge ngxin( );break;case 3:liebiao();break;case '0':flog=1;break;

10、default:printf("输入有误,请按回车键重新输入 n");gets(lj);break;if(flog)break;3、信息查询函数:void chax un()char i,lj100;int flog; time_t T; struct tm * time now;time ( &T );time now = localtime ( &T); flog=0;while(1)system("cls");prin tf("nnnnn");printf(" i员工信息查询系统1n");pr

11、in tf(" | n");printf(" | n");prin tf(" | n");prin tf(" |1.按照编号查询| n");prin tf(" | n");prin tf(" | n");prin tf(" | n");prin tf(" |2.按照姓名查询| n");prin tf(" | n");prin tf(" | n");prin tf(" | n")

12、;printf(" |3.按照生日查询| n");prin tf(" | n");prin tf(" | n");prin tf("|0.退出管理系统| n");prin tf(" | n");prin tf(" | n");printf(" | n");printf(”11n");prin tf("%s", asctime (time now);printf("请输入您的选择(数字0-3): n");sc

13、a nf("%c",&i);gets(lj);if(lj0)i='a'switch(i)case '1':bia nhao();break;case 2:xi ngmi ng();break;case 3:she ngri();break;case 'O':flog=1;break;default:printf("输入有误,请重新输入 n");gets(lj);break;if(flog)break;4、信息更新函数:void gengxin()char i,lj100;time_t T;int f

14、log;struct tm * time now;time ( &T );time now = localtime ( &T); flog=O;while(1)printf(" i员工信息更新系统1prin tf(" |prin tf(" |printf(" |prin tf(" |1.员工信息添加prin tf(" |prin tf(" |prin tf(" |prin tf(" |2.员工信息删除prin tf(" |prin tf(" |prin tf("

15、; |prin tf(" |3.员工信息修改printf(" |prin tf(" |prin tf(" |printf(" |0. 退出管理系统prin tf(" |prin tf(" |printf(" |printf(”11system("cls"); prin tf("nnnnn");prin tf(" %s",asctime (time now);printf(" 请输入您的选择(数字0-3): n"); sca nf(&qu

16、ot;%c",&i);gets(lj);if(ljO)i='a'n"); I n"); I n"); I n"); I n"); I n"); I n"); I n"); I n"); I n"); I n"); I n"); I n"); I n"); I n"); I n"); I n"); I n"); I n"); I n");n");switc

17、h(i) case '1':tianjia();break;case '2':sha nchu();break;case 3:xiugai();break;case 'O':flog=1;break; default:printf("输入有误,请重新输入 n");gets(lj);break;if(flog)break;5、信息一览函数:void liebiao()char lj100; struct emp *p;p=head; system("cls");if(head=NULL)printf(&quo

18、t;查找不到信息 n");menu();printf("员工信息列表 n");printf(" 编号tt 姓名tt 年龄tt 性别tt出生年月tt 电话tt 学历tt 职务tt住址:n");if(head!=NULL)while(p!=NULL)display(p);p=p->n ext; printf("n 按回车键返回主菜单n");gets(lj);四、调试分析4.1、时间复杂度分析在源程序的各个模块,时间复杂读为O(n),并且随着输入信息量的增加,从而时间复杂度也逐渐增加。4.2、问题解决在程序设计过程中,本程序

19、采用两种方式进行数据输入,一种是由用户手动输入数 据,另一种是由文本文件数据导入 的方式。但在文本导入过程中,导入的是二进制文件, 但由于复杂程度较高,从而根据所查资料进行修改,采用导入文本文件。在结果输出上,由于输出的是黑屏,所以经过查阅资料,运用system函数对输出结果的页面进行修饰。4.3、设计收获在做实验前,一定要将课本上的知识吃透,因为这是做实验的基础,否则,在做设 计程序实验时,这将使你做的难度加大,浪费宝贵的时间,使你事倍功半。做实验时, 一定要亲力亲为,务必要将每个步骤,每个细节弄清楚,弄明白。实验后,还要复习, 思考,这样,你的印象才深刻,记得才牢固,否则,过后不久你就会忘

20、得一干二净,这 还不如不做。通过这次程序设计的实验,使我们学到了不少实用的知识,更重要的是, 做实验的过程,思考问题的方法,这与做其他的实验是通用的,真正使我们们受益匪浅。五、测试结果1、菜单函数的测试结果如图2图22、信息查询函数的测试结果如图3图33、信息更新函数测试结果如图4图4六、用户使用说明本程序实在环境下通过编译并执行。 用户根据提示信息进行选择并操作。七、附录源程序:#i nclude <stdio.h>#i nclude <malloc.h>#i nclude <stdlib.h>#i nclude <wi ndows.h>/清屏

21、函数头文件#include <string.h>#in clude <time.h>#i nclude <io.h>#defi ne LEN sizeof(struct emp)#defi ne DATA "employee.txt" struct emplong int num; /编号char n ame20;/ 姓名/int age; / char sex4;/char birthday10;char tel15; / 电话char edu8;/学历char pos20;/职务char add30;/住址struct emp *n

22、ext;struct emp *head=NULL;int t=0;void menu();void gengxin();void tianjia();void in sert(struct emp *em); void display(struct emp *p); void liebiao();void chax un();void bia nhao();void she ngri();void xingmin g();void readDate();void writeDate();void freeAll();void sha nchu();void cha nge();void de

23、vise(struct emp *p); void mai n()struct emp *head=NULL;head=(struct emp *)malloc(LEN);head->next=NULL;system("color F1");system("mode con: cols=500 lines=1000");readDate();me nu();system("cls");prin tf("nnnnnnnnnnnnnnnnnnn");printf("谢谢使用,再见n");voi

24、d menu( void)char i,lj100;int flog;time_t T;struct tm * time now;time ( &T );time now = localtime ( &T);flog=0;while(1)system("cls");prin tf("nnnnn");printf("i员工信息管理系统1n");prin tf("| n");prin tf("| n");printf("| n");prin tf("|1

25、.员工信息查询| n");prin tf("| n");printf("| n");prin tf("| n");prin tf("|2.员工信息更新| n");prin tf("| n");prin tf("| n");prin tf("| n");prin tf("|3.员工信息列表| n");printf("| n");prin tf("| n");prin tf("|

26、n");printf("|0.退出管理系统| n");prin tf("| n");prin tf("| n");printf("| n");printf("11n");prin tf(" %s", asctime (time now); printf(" 请输入您的选择(数字0-3): n"); sca nf("%c",&i);gets(lj);if(lj0)i='a'switch(i)case &#

27、39;1':chax un( );break;case '2':ge ngxin( );break;case 3:liebiao();break;case '0':flog=1;break;default:printf("输入有误,请按回车键重新输入n");gets(lj);break;if(flog)break;void tianjia()struct emp *p,*p1;char lj100;p=NULL;p仁head;printf(" 请输入第c个员工的信息.n",t+1);p=(struct emp *)

28、malloc(LEN);if(p=NULL)printf("分配空间失败");exit(0);printf("请输入员工的编号:n");sca nf("%ld",&p-> nu m);while(p1!=NULL )&&(p-> num!=p1-> num)p 1=p1-> next; if(p1!=NULL)if(p->num=p1- >num)printf("编号已经存在,请重新输入,按回车键继续:n");sca nf("%s",p

29、->n ame); sca nf("%d",&p->age); sca nf("%s",p->sex);free(p);gets(lj);getchar(); printf("请输入员工的姓名:n");printf("请输入员工的年龄:n");printf("请输入员工的性别:n");printf(”请输入员工的出生年月:n"); scanf("%s",p->birthday);sca nf("%s",p->

30、tel); sca nf("%s",p->edu); sca nf("%s",p->pos);sca nf("%s",p->add);printf("请输入员工的电话:n");printf("请输入员工的学历:n");printf("请输入员工的职务:n");printf("请输入员工的住址:n");insert(p); printf("输入的员工信息为:n");printf(":n");print

31、f(" 编号tt 姓名tt年龄tt性别tt出生年月tt 电话tt 学历tt职务tt 住址:n");display(p);printf(" 按 回车键继续 n");writeDate();gets(lj);getchar();void in sert(struct emp *em)struct emp *p0,*p1,*p2;p仁head;p0=em;if(head=NULL) head=p0;p0-> next=NULL; elsewhile(p0->num > p1->num)&&(p1->next!=NU

32、LL)p2=p1;p1=p1- >n ext; if(pO->num v=p1- >num)if(head=p1)head=pO;elsep2->n ext=pO;pO->n ext=p1;elsep1-> next=pO; pO-> next=NULL; t+;void display(struct emp *p)pri ntf("%ldtt%stt%dtt%stt%stt%stt%stt%stt%sn",p-> num,p->n ame,p->age,p->sex,p->birthday,p->

33、;tel,p->edu,p->pos,p->add);void liebiao()char lj100; struct emp *p;p=head; system("cls");if(head=NULL)printf("查找不到信息 n");menu();printf("员工信息列表 n");printf("编号tt 姓名tt 年龄tt 性别tt出生年月tt 电话tt学历tt职务tt住址:n");if(head!=NULL)while(p!=NULL) display(p);p=p-> ne

34、xt; printf("n按回车键返回主菜单n");gets(lj);void chax un()char i,lj100;int flog;time_t T;struct tm * time now;time ( &T );time now = localtime ( &T);flog=O;while(1)system("cls");prin tf("nnnnn");printf(" i员工信息查询系统1n");prin tf(" | n");printf(" | n

35、");prin tf(" | n");prin tf(" |1.按照编号查询| n");printf(" | n");prin tf(" | n");prin tf(" | n");prin tf(" |2.按照姓名查询| n");printf(" | n");prin tf(" | n");prin tf(" | n");prin tf(" |3.按照生日查询| n");printf(

36、" | n");prin tf(" | n");prin tf(" |0.退出管理系统| n");printf(" | n");prin tf(" | n");prin tf(" | n");printf("11n");prin tf("%s", asctime (time now);printf(" 请输入您的选择(数字0-3): n");sca nf("%c",&i);gets(lj)

37、;if(lj0)i='a'switch(i)case '1':bia nhao();break;case 2:xi ngmi ng();break;case 3:she ngri();break;case '0':flog=1;break;default:printf("输入有误,请重新输入 n");gets(lj);break;if(flog)break;void bia nhao()int number;char lj100;struct emp *p1;p仁head;printf(" 请输入要查询员工的编号:n

38、");sca nf("%d",&n umber);while( nu mber!=p1-> num)&&(p1-> next!=NULL)p1=p1- >n ext; if(nu mber=p1- >num)printf(" 员工信息查询 n");printf(" 要查询的员工信息:n");printf("编号tt 姓名tt 年龄tt 性别tt出生年月tt 电话tt 学历tt职务tt住址:n");prin tf("%ldtt%stt%dtt%stt

39、%stt%stt%stt%stt%sn",p1-> nu m,p1->n ame,p1->age,p1->sex,p1->birthday,p1->tel,p1->edu,p1->pos,p1->add);printf("按回车键继续 n");gets(lj); getchar();else if(p1-> next=NULL) prin tf("要查询的员工信息不存在,按回车键返回:n");gets(lj);getchar();void xin gmi ng()char ch10;s

40、truct emp *p;char lj100;p=head;printf("请输入要查询的员工的名字:n");sca nf("%s",ch);if(p=NULL)printf("不存在员工记录,按回车键返回.n");gets(lj); getchar(); return ;while(strcmp(ch,p->n ame)&&p->n ext!=NULL)p=p->n ext;if(!strcmp(ch,p->n ame) printf("员工信息查询n");printf(

41、"编号tt姓名tt 年龄tt 性别tt出生年月tt 电话tt 学历tt职务tt 住址:n"); display(p);printf("按回车键继续 n");gets(lj);getchar();else if(p-> next=NULL)printf("不存在员工记录.n");gets(lj);getchar(); return;void she ngri()char bir20,lj100;struct emp *p;p=head;prin tf("请输入要查询的员工的出生日期:n");sca nf(&qu

42、ot;%s",bir);if(p=NULL)printf(" 不存在员工记录.按回车键返回n");gets(lj);getchar(); return ;while(strcmp(bir,p->birthday)&&p-> next!=NULL)p=p->n ext;if(!strcmp(bir,p->n ame)prin tf("员工信息查询 n");printf("编号tt姓名tt 年龄tt 性别tt出生年月tt 电话tt 学历tt职务tt 住址:n"); display(p);p

43、rintf("按回车键继续 n");gets(lj);getchar(); else if(p-> next=NULL)printf(" 不存在员工记录.按回车键返回n");gets(lj);getchar(); return;void readDate()FILE * fp;struct emp *p1,*p2;fp=fope n(DATA, "r");if(!fp)printf("打开文件失败!按回车键继续n");getchar();elsefscanf(fp,"%dn",&t

44、);head=p1=p2=(struct emp *)malloc(LEN);fsca nf(fp,"%ldtt%stt%dtt%stt%stt%stt%stt%stt%sn",&p1-> num,p1- >n ame,&p1->age,p1->sex,p1->birthday,p1->tel,p1->edu,p1->pos,p1->add); while(!feof(fp)p1=(struct emp *)malloc(LEN);fsca nf(fp,"%ldtt%stt%dtt%stt%st

45、t%stt%stt%stt%sn",&p1-> num,p1- >n ame,&p1->age,p1->sex,p1->birthday,p1->tel,p1->edu,p1->pos,p1->add);p2-> next=p1;p2=p1;p2-> next=NULL;fclose(fp);void writeDate()FILE* fp; struct emp *p1;fp=fope n(DATA, "w");if(!fp)printf("打开文件失败!n")

46、;getchar();elsefprin tf(fp,"%dn",t);for(p1=head;p1!=NULL;p 1= p1-> next)fprin tf(fp,"%ldtt%stt%dtt%stt%stt%stt%stt%stt%sn",p1-> num,p1- >n ame,p1->age,p1->sex,p1->birthday,p1->tel,p1->edu,p1->pos,p1->add); fclose(fp);void freeAll()struct emp *p1,*p2;

47、 p1=p2=head;while(p1)p2=p1-> next;free(p1);p1=p2; void sha nchu()struct emp *p1,*p2; long int nu mber;char lj100;if(head=NULL)printf("无员工纪录!按回车键返回n");gets(lj);getchar();return;printf("请输入你要删除的员工的编号:n");sca nf("%ld",&nu mber);p仁 head;while( nu mber!=p1-> num&am

48、p;&p1-> next!=NULL)p2=p1;p仁 p1-> next;if(nu mber=p1- >num)if(p1=head)head=p1- >n ext;else p2->n ext=p1- >n ext;free(p1);t-;writeDate();printf("删除成功,按回车键继续 n"); elseprintf(" 没有该员工的纪录,请核对.按回车键返回n");gets(lj);getchar();void xiugai()struct emp *p1,*p2;long int nu

49、 mber;char lj100;if(head=NULL)printf("无员工纪录!按回车键返回n");gets(lj);getchar();return;printf("请输入你要修改的员工的编号:n");sca nf("%ld",&nu mber);gets(lj);p仁head;while( nu mber!=p1-> num&&p1-> next!=NULL)p2=p1;p1=p1- >n ext;if(nu mber=p1- >num)devise(p1);writeDat

50、e();printf("修改成功,按回车键继续n");elseprintf("没有该员工的纪录,请核对.按回车键返回n");gets(lj);getchar();void devise(struct emp *p)char i,lj100;int flog;time_t T;struct tm * time now;time ( &T );time now = localtime ( &T);flog=0;while(1)system("cls"); prin tf("nnnnn");printf("i员工信息修改1n");prin tf(" | n");prin tf(" | n");printf(" | n");prin tf(" |1.修改员工姓名| n");prin tf(" | n");prin tf(" | n")

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

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1