1、将线性表L重置为空表。ADT Graph2)本程序是由几个函数构成的:1主函数:main()2菜单函数menu();3文件读入函数:read data();4文件写入函数:write data();5信息查询函数:chaxun();6信息更新函数:gengxin();7信息一览函数:liebiao();8数据删除函数:shanchu();9数据添加函数:tianjia();10数据修改函数:xiugai();它们的调用关系如3、 详细设计#include malloc.hstdlib.hwindows.h /清屏函数头文件string.htime.hio.h#define LEN sizeof
2、(struct emp)#define DATA employee.txtstruct emp long 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(stru
3、ct 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
4、;system(color 1f); system(mode con: cols=150 lines=500 readDate();menu();cls printf(nnnnnnnnnnnnnnnnnnn 谢谢使用,再见nvoid menu(void) char i,lj100; int flog;time_t T; struct tm * timenow; time ( &T );timenow = localtime ( & flog=0; while(1) system(nnnnn printf( 员工信息管理系统n n 1.员工信息查询 n 2.员工信息更新 n 3.员工信息列表 n
5、 0.退出管理系统 n n %s, asctime (timenow) );请输入您的选择(数字0-3):n scanf(%c,&i);gets(lj); if(lj0)i=a; switch(i) case 1:break;23liebiao();0flog=1; default:printf(输入有误,请按回车键重新输入n if(flog)break; void tianjia() struct emp *p,*p1; char lj100; p=NULL;p1=head;请输入第%d个员工的信息.n,t+1); p=(struct emp *)malloc(LEN); if(p=NULL
6、) printf(分配空间失败 exit(0);请输入员工的编号: scanf(%ldp-num); while(p1!=NULL)&(p-num!=p1-num)p1=p1-next; if(p1!=NULL) if(p-num=p1-num) printf(编号已经存在,请重新输入,按回车键继续: free(p);getchar();请输入员工的姓名:%s,p-name);请输入员工的年龄:%dage);请输入员工的性别:sex);请输入员工的出生年月:birthday);请输入员工的电话:tel);请输入员工的学历:edu);请输入员工的职务:pos);请输入员工的住址:add); in
7、sert(p);输入的员工信息为:-:编号tt姓名tt年龄tt性别tt出生年月tt电话tt学历tt职务tt住址: display(p);按回车键继续nwriteDate(); gets(lj);void insert(struct emp *em) struct emp *p0,*p1,*p2; p1=head; p0=em; if(head=NULL) head=p0;p0- else while(p0-num p1-num)&(p1-next!=NULL) p2=p1; p1=p1- if(p0-numnext=p0;next=p1; else p1- p0- t+;void displa
8、y(struct emp *p)printf(%ldtt%stt%dtt%stt%stt%stt%stt%stt%snnum,p-name,p-age,p-sex,p-birthday,p-tel,p-edu,p-pos,p-void liebiao() struct emp *p; p=head; if(head=NULL)printf(查找不到信息n员工信息列表n编号tt姓名tt年龄tt性别tt出生年月tt电话tt学历tt职务tt住址 : if(head! while(p!=NULL) display(p);p=p- n按回车键返回主菜单nvoid chaxun() time_t T; 员
9、工信息查询系统n 1.按照编号查询 n 2.按照姓名查询 n 3.按照生日查询 nbianhao(); case xingming();shengri();输入有误,请重新输入nvoid bianhao() int number;char lj100; struct emp *p1;请输入要查询员工的编号:number); while(number! p1=p1- if(number=p1-员工信息查询n要查询的员工信息:,p1-num,p1-name,p1-age,p1-sex,p1-birthday,p1-tel,p1-edu,p1-pos,p1- getchar(); else if(p
10、1-next=NULL) printf(要查询的员工信息不存在,按回车键返回: gets(lj);void xingming() char ch10;struct emp *p;p=head;请输入要查询的员工的名字:,ch);if(p=NULL)不存在员工记录,按回车键返回.n return ; while(strcmp(ch,p-name)& p=p- if(!strcmp(ch,p-name) else if(p-不存在员工记录.n getchar(); return;void shengri() char bir20,lj100;请输入要查询的员工的出生日期:,bir);不存在员工记录
11、.按回车键返回n while(strcmp(bir,p-birthday)&strcmp(bir,p-void readDate() FILE * fp;struct emp *p1,*p2;fp=fopen(DATA, rfp)打开文件失败! fscanf(fp,%dnt);head=p1=p2=(struct emp *)malloc(LEN); fscanf(fp,p1-name,& while(!feof(fp) p1=(struct emp *)malloc(LEN); fscanf(fp, p2- p2=p1; p2-fclose(fp);void writeDate() FILE
12、* fp;wremove(fp); else fprintf(fp,t);for(p1=head;p1!=NULL;p1=p1-next) fprintf(fp, fclose(fp);void freeAll() struct emp *p1,*p2; p1=p2=head; while(p1) p2=p1-free(p1);p1=p2;void shanchu() long int number;无员工纪录!按回车键返回nreturn;请输入你要删除的员工的编号: while(number!num& p2=p1; if(p1=head)head=p1- else p2-next=p1- free(p1);t-; writeDate();删除成功,按回车键继续n else没有该员工的纪录,请核对.按回车键返回nvoid xiugai() return;请输入你要修改的员工的编号: p2=p1; p1=p1- devise(p1);修改成功,按回车键继续nvoid devise(struct emp *p)timenow