数据结构c语言员工信息管理系统.doc_第1页
数据结构c语言员工信息管理系统.doc_第2页
数据结构c语言员工信息管理系统.doc_第3页
数据结构c语言员工信息管理系统.doc_第4页
数据结构c语言员工信息管理系统.doc_第5页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

拧成一股绳,搏尽一份力,狠下一条心,共圆一个梦。数据结构实习报告 -信息管理 学校 石家庄铁道大学 指导老师 张翠肖 班级 信0901-1班 学号 20082406 姓名 张洁 院系 信息分院 2011.07.05学生信息管理系统一、 需求分析本程序主要是执行链表的删除插入等功能根据程序提示我们可以添加、修改、删除员工信息并能进行多种方式的查询还有员工信息一览二、 概要设计1) 为了实现上述功能需要定义一下抽象的数据类型:ADT List数据对象:D=ai|aiElemSeti=12nn=0数据关系:R1=|ai-1aiDi=12n基本操作:Init List(&L);操作结果:构造一个空的线性表LDestroyList(&L);初始条件:线性表L存在操作结果:销毁线性表LLocateElem(LI&e);初始条件:线性表L存在1iListlength(L)操作结果:用e返回线性表L中第i个数据元素的值ClearList(&L);初始条件:线性表L存在操作结果:将线性表L重置为空表ADT Graph2) 本程序是由几个函数构成的: 主函数:main() 菜单函数menu(); 文件读入函数:read data(); 文件写入函数:write data(); 信息查询函数:chaxun(); 信息更新函数:gengxin(); 信息一览函数:liebiao(); 数据删除函数:shanchu(); 数据添加函数:tianjia(); 数据修改函数:xiugai();它们的调用关系如三、 详细设计#include #include #include #include /清屏函数头文件#include #include #include #define LEN sizeof(struct emp)#define DATA employee.txtstruct emplong int num; /编号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();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 1f);system(mode con: cols=150 lines=500);readDate();menu();system(cls);printf(nnnnnnnnnnnnnnnnnnn);printf( 谢谢使用再见n);void menu(void)char ilj100;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);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);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=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()struct emp *p*p1;char lj100;p=NULL;p1=head;printf(请输入第%d个员工的信息.nt+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(p-num=p1-num)printf(编号已经存在请重新输入按回车键继续:n);free(p);gets(lj);getchar();printf(请输入员工的姓名:n);scanf(%sp-name);printf(请输入员工的年龄:n);scanf(%d&p-age);printf(请输入员工的性别:n);scanf(%sp-sex);printf(请输入员工的出生年月:n);scanf(%sp-birthday);printf(请输入员工的电话:n);scanf(%sp-tel);printf(请输入员工的学历:n);scanf(%sp-edu);printf(请输入员工的职务:n);scanf(%sp-pos);printf(请输入员工的住址:n);scanf(%sp-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=NULL;elsewhile(p0-num p1-num)&(p1-next!=NULL)p2=p1;p1=p1-next;if(p0-numnum)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%snp-nump-namep-agep-sexp-birthdayp-telp-edup-posp-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-next;printf(n按回车键返回主菜单n);gets(lj);void chaxun()char ilj100;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);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);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=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(请输入要查询员工的编号: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%snp1-nump1-namep1-agep1-sexp1-birthdayp1-telp1-edup1-posp1-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=head;printf(请输入要查询的员工的名字:n);scanf(%sch);if(p=NULL)printf(不存在员工记录按回车键返回.n);gets(lj);getchar();return ;while(strcmp(chp-name)&p-next!=NULL)p=p-next;if(!strcmp(chp-name)printf(员工信息查询n);printf(编号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 shengri() char bir20lj100;struct emp *p;p=head;printf(请输入要查询的员工的出生日期:n);scanf(%sbir);if(p=NULL)printf(不存在员工记录.按回车键返回n);gets(lj);getchar();return ;while(strcmp(birp-birthday)&p-next!=NULL)p=p-next;if(!strcmp(birp-name)printf(员工信息查询n);printf(编号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 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%stt%dtt%stt%stt%stt%stt%stt%sn&p1-nump1-name&p1-agep1-sexp1-birthdayp1-telp1-edup1-posp1-add);while(!feof(fp)p1=(struct emp *)malloc(LEN);fscanf(fp%ldtt%stt%dtt%stt%stt%stt%stt%stt%sn&p1-nump1-name&p1-agep1-sexp1-birthdayp1-telp1-edup1-posp1-add);p2-next=p1;p2=p1;p2-next=NULL;fclose(fp);void writeDate()FILE* fp;struct emp *p1;fp=fopen(DATA w);if(!fp)printf(打开文件失败!n);remove(fp);getchar();else fprintf(fp%dnt);for(p1=head;p1!=NULL;p1=p1-next)fprintf(fp%ldtt%stt%dtt%stt%stt%stt%stt%stt%snp1-nump1-namep1-agep1-sexp1-birthdayp1-telp1-edup1-posp1-add);fclose(fp);void freeAll()struct emp *p1*p2;p1=p2=head;while(p1)p2=p1-next;free(p1);p1=p2;void shanchu()struct emp *p1*p2;long int number;char lj100;if(head=NULL)printf(无员工纪录!按回车键返回n);gets(lj);getchar();return;printf(请输入你要删除的员工的编号:n);scanf(%ld&number);p1=head;while(number!=p1-num&p1-next!=NULL)p2=p1;p1=p1-next;if(number=p1-num)if(p1=head)head=p1-next;else p2-next=p1-next;free(p1);t-;writeDate();printf(删除成功按回车键继续n);elseprintf(没有该员工的纪录请核对.按回车键返回n);gets(lj);getchar();void xiugai()struct emp *p1*p2;long int number;char lj

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论