




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、 成 绩12信计2013-2014(一)数 据 结 构 课 程 设 计设计题目 员工信息管理系统 设计时间 学生姓名 葛考 学生学号 20120402127 所在班级 12精算 指导教师 刘 风 华 徐州工程学院数学与物理科学学院题目 员工信息管理系统 一、 需求分析员工信息管理系统设计,具体功能如下:1、系统以菜单方式工作,应为用户提供清晰的使用提示,依据用户的选择来进行各种处理,并且在此过程中能够尽可能的兼容用户使用过程中的输入异常情况。2、员工信息录入系统(员工信息用文件保存),注意员工按员工编号进行区分,即每个员工的员工编号都是唯一的,不允许出现两个员工或员工编号相同的情况。3、可对员
2、工信息进行查询,具体分为:按姓名查询、按员工号查询、按生日查询;4、可对员工信息进行删除;5、可对员工信息进行修改,但应注意员工号不能修改,修改应逐个进行,一个员工记录的更改不应影响其他的员工记录;6、可对全部的员工信息进行显示v(员工信息浏览),注意员工信息的显示规范;员工信息应包括姓名、员工编号、性别、年龄、生日、学历、职务、联系电话、住址。二、概要设计2.1、抽象数据类型ADT List数据对象:D=ai|aiElemSet,i=1,2,······,n,n>=0数据关系:R1=<ai-1,ai>|ai-1,a
3、iD,i=1,2,······,n基本操作:Init List(&L);操作结果:构造一个空的线性表L。DestroyList(&L);初始条件:线性表L存在。操作结果:销毁线性表L。LocateElem(L,I,&e);初始条件:线性表L存在,1<i<Listlength(L)。操作结果:用e返回线性表L中第i个数据元素的值。ClearList(&L);初始条件:线性表L存在。操作结果:将线性表L重置为空表。ADT Graph2.2、程序流程系统的执行从菜单的选择开始,依据用户的选择进行相
4、应的处理,直到用户选择退出系统为止。其间应对用户的选择做出判断及异常处理。系统的流程如图1所示:图1 员工信息管理系统流程图三、详细设计3.1函数构成 (1)主函数:void main();(2)文件读入函数:void read data();(3)文件写入函数:void write data();(4)菜单函数函数原型:void Menu()功能:此函数的功能为依据用户选择的功能来进行相应的处理,直到用户选择退出系统为止,包括员工信息的查询、更新、列表及退出管理;(5)信息查询函数函数原型:void chaxun()功能:该函数的功能是按照用户的选择进行不同方式的查找,本程序实现了按三种方式
5、进行查找,包括按编号、姓名、生日查找;(6)信息更新函数函数原型:void gengxin()功能:此函数的功能为使用户修改记录。首先判断用户要修改的记录是否存在,因为只有员工编号是唯一的,所以根据员工编号进行查找。若存在则用用户输入的新的信息替换原信息;若不存在则函数结束。在此函数中要注意的是文件的打开方式应为”rb+”,因为在这个函数中不仅要读文件,还要向文件中写入数据,所以要用读写的方式打开二进制文件;(7)信息一览函数函数原型:void liebiao()功能:此函数的功能为从文件中依次取出每条记录并将其显示出来。因为只需读文件不需要向文件中写入数据,所以文件的打开方式是只读。3.2模
6、块程序清单(详细程序见附录)1、员工信息的结构体:Typedef struct emplong int num; /编号char name20; /姓名int age; /年龄char sex4; /性别char birthday10; /生日char tel15; /电话char edu8; /学历char pos20; /职务char add30; /住址struct emp *next;2、菜单函数:void menu(void) char i,lj100;int flog;time_t T;struct tm * timenow;time ( &T );timenow = lo
7、caltime ( &T );flog=0;while(1)system("cls");printf("nnnnn");printf(" 员工信息管理系统n");printf(" n");printf(" n");printf(" n");printf(" 1.员工信息查询 n");printf(" n");printf(" n");printf(" n");printf(" 2
8、.员工信息更新 n");printf(" n");printf(" n");printf(" n");printf(" 3.员工信息列表 n");printf(" n");printf(" n");printf(" n");printf(" 0.退出管理系统 n");printf(" n");printf(" n");printf(" n");printf("
9、; n");printf(" %s", asctime (timenow) ); printf("请输入您的选择(数字0-3):n");scanf("%c",&i);gets(lj);if(lj0)i='a'switch(i) case '1':chaxun();break;case '2':gengxin();break;case '3':liebiao();break;case '0':flog=1;break;default:pri
10、ntf("输入有误,请按回车键重新输入n");gets(lj);break;if(flog)break;3、信息查询函数:void chaxun()char i,lj100;int flog;time_t T;struct tm * timenow;time ( &T );timenow = localtime ( &T ); flog=0;while(1)system("cls");printf("nnnnn");printf("员工信息查询系统n");printf(" n")
11、;printf(" n");printf(" n");printf(" 1.按照编号查询 n");printf(" n");printf(" n");printf(" n");printf(" 2.按照姓名查询 n");printf(" n");printf(" n");printf(" n");printf(" 3.按照生日查询 n");printf(" n&quo
12、t;);printf(" n");printf(" 0.退出管理系统 n");printf(" n");printf(" n");printf(" n");printf("n");printf("%s", asctime (timenow) ); printf("请输入您的选择(数字0-3):n");scanf("%c",&i);gets(lj);if(lj0)i='a'switch(i) c
13、ase '1':bianhao();break;case '2':xingming();break; case '3':shengri();break;case '0':flog=1;break; default:printf("输入有误,请重新输入n");gets(lj);break;if(flog)break;4、信息更新函数:void gengxin()char i,lj100;time_t T;int flog;struct tm * timenow;time ( &T );timenow =
14、localtime ( &T ); flog=0;while(1)system("cls");printf("nnnnn");printf("员工信息更新系统n");printf(" n");printf(" n");printf(" n");printf(" 1.员工信息添加 n");printf(" n");printf(" n");printf(" n");printf("
15、 2.员工信息删除 n");printf(" n");printf(" n");printf(" n");printf(" 3.员工信息修改 n");printf(" n");printf(" n");printf(" n");printf(" 0.退出管理系统 n");printf(" n");printf(" n");printf(" n");printf(&qu
16、ot;n");printf(" %s",asctime (timenow) ); printf("请输入您的选择(数字0-3):n");scanf("%c",&i);gets(lj);if(lj0)i='a'switch(i) case '1':tianjia();break; case '2':shanchu();break; case '3':xiugai();break; case '0':flog=1;break; default
17、:printf("输入有误,请重新输入n");gets(lj);break;if(flog)break;5、信息一览函数: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!=
18、NULL)display(p);p=p->next;printf("n按回车键返回主菜单n");gets(lj);四、调试分析4.1、时间复杂度分析在源程序的各个模块,时间复杂读为,并且随着输入信息量的增加,从而时间复杂度也逐渐增加。4.2、问题解决在程序设计过程中,本程序采用两种方式进行数据输入,一种是由用户手动输入数据,另一种是由文本文件数据导入1的方式。但在文本导入过程中,导入的是二进制文件,但由于复杂程度较高,从而根据所查资料进行修改,采用导入文本文件。在结果输出上,由于输出的是黑屏,所以经过查阅资料,运用函数对输出结果的页面进行修饰。4.3、设计收获在做实验
19、前,一定要将课本上的知识吃透,因为这是做实验的基础,否则,在做设计程序实验时,这将使你做的难度加大,浪费宝贵的时间,使你事倍功半。做实验时,一定要亲力亲为,务必要将每个步骤,每个细节弄清楚,弄明白。实验后,还要复习,思考,这样,你的印象才深刻,记得才牢固,否则,过后不久你就会忘得一干二净,这还不如不做。通过这次程序设计的实验,使我们学到了不少实用的知识,更重要的是,做实验的过程,思考问题的方法,这与做其他的实验是通用的,真正使我们们受益匪浅。五、测试结果1、菜单函数的测试结果如图2图22、信息查询函数的测试结果如图3图33、信息更新函数测试结果如图4图4六、用户使用说明本程序实在VB.6.0环
20、境下通过编译并执行。用户根据提示信息进行选择并操作。七、附录源程序:#include <stdio.h>#include <malloc.h>#include <stdlib.h>#include <windows.h> /清屏函数头文件#include <string.h>#include <time.h>#include <io.h>#define LEN sizeof(struct emp)#define DATA "employee.txt"struct emplong int nu
21、m; /编号char name20; /姓名int age; /年龄char sex4; /性别char birthday10; /生日char tel15;/电话char edu8; /学历char pos20; /职务char add30; /住址struct emp *next;struct emp *head=NULL;int t=0;void menu();void gengxin();void tianjia();void insert(struct emp *em);void display(struct emp *p);void liebiao();void chaxun();
22、void bianhao();void shengri();void xingming();void readDate();void writeDate();void freeAll();void shanchu();void change();void devise(struct emp *p);void main()struct emp *head=NULL;head=(struct emp *)malloc(LEN);head->next=NULL;system("color F1");system("mode con: cols=500 lines=
23、1000");readDate();menu();system("cls");printf("nnnnnnnnnnnnnnnnnnn");printf(" 谢谢使用,再见n");void menu(void)char i,lj100;int flog;time_t T;struct tm * timenow;time ( &T );timenow = localtime ( &T );flog=0;while(1)system("cls");printf("nnnnn"
24、);printf(" 员工信息管理系统n");printf(" n");printf(" n");printf(" n");printf(" 1.员工信息查询 n");printf(" n");printf(" n");printf(" n");printf(" 2.员工信息更新 n");printf(" n");printf(" n");printf(" n&quo
25、t;);printf(" 3.员工信息列表 n");printf(" n");printf(" n");printf(" n");printf(" 0.退出管理系统 n");printf(" n");printf(" n");printf(" n");printf(" n");printf(" %s", asctime (timenow) ); printf("请输入您的选择(数字0-3
26、):n");scanf("%c",&i);gets(lj);if(lj0)i='a'switch(i) case '1':chaxun();break; case '2':gengxin();break; case '3':liebiao();break; case '0':flog=1;break; default:printf("输入有误,请按回车键重新输入n");gets(lj);break;if(flog)break;void tianjia()st
27、ruct emp *p,*p1;char lj100;p=NULL;p1=head;printf("请输入第%d个员工的信息.n",t+1);p=(struct emp *)malloc(LEN);if(p=NULL)printf("分配空间失败");exit(0);printf("请输入员工的编号:n");scanf("%ld",&p->num);while(p1!=NULL)&&(p->num!=p1->num)p1=p1->next;if(p1!=NULL)if
28、(p->num=p1->num)printf("编号已经存在,请重新输入,按回车键继续:n");free(p);gets(lj);getchar();printf("请输入员工的姓名:n");scanf("%s",p->name);printf("请输入员工的年龄:n");scanf("%d",&p->age);printf("请输入员工的性别:n");scanf("%s",p->sex);printf("请
29、输入员工的出生年月:n");scanf("%s",p->birthday);printf("请输入员工的电话:n");scanf("%s",p->tel);printf("请输入员工的学历:n");scanf("%s",p->edu);printf("请输入员工的职务:n");scanf("%s",p->pos);printf("请输入员工的住址:n");scanf("%s",p-&
30、gt;add);insert(p);printf("输入的员工信息为:n");printf("-:n");printf("编号tt姓名tt年龄tt性别tt出生年月tt电话tt学历tt职务tt住址:n");display(p);printf("按回车键继续n");writeDate();gets(lj);getchar();void insert(struct emp *em)struct emp *p0,*p1,*p2;p1=head;p0=em;if(head=NULL)head=p0;p0->next=N
31、ULL;elsewhile(p0->num > p1->num)&&(p1->next!=NULL)p2=p1;p1=p1->next;if(p0->num<=p1->num)if(head=p1)head=p0;elsep2->next=p0;p0->next=p1;elsep1->next=p0;p0->next=NULL;t+;void display(struct emp *p)printf("%ldtt%stt%dtt%stt%stt%stt%stt%stt%sn",p->
32、;num,p->name,p->age,p->sex,p->birthday,p->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
33、(head!=NULL)while(p!=NULL)display(p);p=p->next;printf("n按回车键返回主菜单n");gets(lj);void chaxun()char i,lj100;int flog;time_t T;struct tm * timenow;time ( &T );timenow = localtime ( &T );flog=0;while(1)system("cls");printf("nnnnn");printf("员工信息查询系统n");pri
34、ntf(" n");printf(" n");printf(" n");printf(" 1.按照编号查询 n");printf(" n");printf(" n");printf(" n");printf(" 2.按照姓名查询 n");printf(" n");printf(" n");printf(" n");printf(" 3.按照生日查询 n");
35、printf(" n");printf(" n");printf(" 0.退出管理系统 n");printf(" n");printf(" n");printf(" n");printf("n");printf("%s", asctime (timenow) ); printf("请输入您的选择(数字0-3):n");scanf("%c",&i);gets(lj);if(lj0)i=
36、9;a'switch(i) case '1':bianhao();break;case '2':xingming();break; case '3':shengri();break;case '0':flog=1;break; default:printf("输入有误,请重新输入n");gets(lj);break;if(flog)break;void bianhao()int number;char lj100;struct emp *p1;p1=head;printf("请输入要查询员工的
37、编号:n");scanf("%d",&number);while(number!=p1->num)&&(p1->next!=NULL)p1=p1->next;if(number=p1->num)printf("员工信息查询n");printf("要查询的员工信息:n");printf("编号tt姓名tt年龄tt性别tt出生年月tt电话tt学历tt职务tt住址:n");printf("%ldtt%stt%dtt%stt%stt%stt%stt%stt
38、%sn",p1->num,p1->name,p1->age,p1->sex,p1->birthday,p1->tel,p1->edu,p1->pos,p1->add);printf("按回车键继续n");gets(lj);getchar();else if(p1->next=NULL)printf("要查询的员工信息不存在,按回车键返回:n");gets(lj);getchar();void xingming() char ch10;struct emp *p;char lj100;p
39、=head;printf("请输入要查询的员工的名字:n");scanf("%s",ch);if(p=NULL)printf("不存在员工记录,按回车键返回.n");gets(lj);getchar();return ;while(strcmp(ch,p->name)&&p->next!=NULL)p=p->next;if(!strcmp(ch,p->name)printf("员工信息查询n");printf("编号tt姓名tt年龄tt性别tt出生年月tt电话tt学
40、历tt职务tt住址:n");display(p);printf("按回车键继续n");gets(lj);getchar();else if(p->next=NULL)printf("不存在员工记录.n");gets(lj);getchar();return;void shengri() char bir20,lj100;struct emp *p;p=head;printf("请输入要查询的员工的出生日期:n");scanf("%s",bir);if(p=NULL)printf("不存在员
41、工记录.按回车键返回n");gets(lj);getchar();return ;while(strcmp(bir,p->birthday)&&p->next!=NULL)p=p->next;if(!strcmp(bir,p->name)printf("员工信息查询n");printf("编号tt姓名tt年龄tt性别tt出生年月tt电话tt学历tt职务tt住址:n");display(p);printf("按回车键继续n");gets(lj);getchar();else if(p-&
42、gt;next=NULL)printf("不存在员工记录.按回车键返回n");gets(lj);getchar();return;void readDate()FILE * fp;struct emp *p1,*p2;fp=fopen(DATA, "r");if(!fp)printf("打开文件失败!按回车键继续n");getchar();elsefscanf(fp,"%dn",&t);head=p1=p2=(struct emp *)malloc(LEN); fscanf(fp,"%ldtt%s
43、tt%dtt%stt%stt%stt%stt%stt%sn",&p1->num,p1->name,&p1->age,p1->sex,p1->birthday,p1->tel,p1->edu,p1->pos,p1->add);while(!feof(fp)p1=(struct emp *)malloc(LEN);fscanf(fp,"%ldtt%stt%dtt%stt%stt%stt%stt%stt%sn",&p1->num,p1->name,&p1->age,p1->sex,p1->birthday,p1->tel,p1->edu,p1->pos,p1->add);p2->next=p1;p2=
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025化工企业之涉外大宗原材料采购合同范本
- 2025年合伙投资合同范本
- 2025年高性能铁氧体一次磁粉项目合作计划书
- 2025年运输货场服务项目合作计划书
- 2025年再生塑料:PVC再生料项目合作计划书
- 2025年家用空气调节器合作协议书
- 2025年Υ射线无损探测仪项目建议书
- 2025年墙画式终端装置合作协议书
- 2025年智能人体秤合作协议书
- 2025年高纯度丙烯酰胺及聚丙烯酰胺合作协议书
- 铁碳合金的相图解读
- 2023年复旦大学博士研究生入学考试专家推荐信模板
- 中小学教师资格证面试课件讲义
- 全国初中英语优质课大赛一等奖《八年级Unit 6An old man》说课课件
- 云南省饮用水生产企业名录534家
- 湖北地区医院详细名单一览表
- 麦肯锡入职培训第一课:让职场新人一生受用的逻辑思考力新员工培训教材
- 苏霍姆林斯基教育思想-PPT课件
- 脊髓损伤康复评定治疗PPT课件
- 金属压铸机的plc控制
- 进制转换(课堂PPT)
评论
0/150
提交评论