c语言课程设计超市员工管理系统.doc

上传人:叶*** 文档编号:35010264 上传时间:2022-08-19 格式:DOC 页数:14 大小:30KB
返回 下载 相关 举报
c语言课程设计超市员工管理系统.doc_第1页
第1页 / 共14页
c语言课程设计超市员工管理系统.doc_第2页
第2页 / 共14页
点击查看更多>>
资源描述

《c语言课程设计超市员工管理系统.doc》由会员分享,可在线阅读,更多相关《c语言课程设计超市员工管理系统.doc(14页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、#include #include #include /清屏函数头文件#include struct Stuff char number10; /员工编号 char name10; /员工姓名 char sex8; /员工性别 char borth10; /员工生日 char degree20; /员工学历 char business20; /员工职务 char phone15; /员工 char place50; /员工住址 char con50; /判断关键字专用 struct Stuff *next; char Menu(void); /菜单显示struct Stuff *App(str

2、uct Stuff *head); /添加void Sort(struct Stuff *head); /排序struct Stuff *Ser(struct Stuff *head); /查找void Chn(struct Stuff *head,char n10); /更改void Scpy(char *p,char *q); /排序中用于交换员工信息struct Stuff *Del(struct Stuff *head,char n10); /删除int Sel(char ch,struct Stuff *p,struct Stuff *q); /判断排序及关键字专用函数void Pr

3、f(struct Stuff *head); /输出void Fre(struct Stuff *head); /释放int i=1; /定义全局变量,实现实时员工人数统计int main(void) char n10; struct Stuff *head=NULL; /链表头指针定义 while(1) switch(Menu() case 1: printf(请输入员工信息,直接输入#完毕n); head=App(head); break; case 2: Sort(head); break; case 3: head=Ser(head); break; case 4: printf(员工

4、信息如下:n); Prf(head); break; case 5: printf(请输入员工编号:); scanf(%s,n); Chn(head,n); break; case 6: printf(请输入员工编号:); scanf(%s,n); head=Del(head,n); break; case 0: printf(欢送下次光临,88!n); exit(0); default: printf(输入错误,请重新输入!n); fflush(stdin); /清楚缓冲区 printf(按任意键继续); getchar(); system(cls); /清屏效果 Fre(head); re

5、turn 0;/菜单函数char Menu(void) char ch; printf(-请选择-n); printf(1.添加员工信息n2.员工信息排序n3.查找员工信息n4.输出员工信息n5.更改员工信息n6.删除员工信息n0.退出n-n); scanf( %c,&ch); return ch;/添加成员函数/输入参数:链表头指针/返回参数:链表头指针struct Stuff *App(struct Stuff *head) struct Stuff *p=NULL,*q=head; while(i) p=(struct Stuff *)malloc(sizeof(struct Stuff

6、); /申请构造体空间 if(p=NULL) printf(内存不够!n); exit(0); p-next =NULL; /指针域为空 printf(请输入第%d名员工:n,i); printf( 编号 | 姓名 | 性别 | 出生年月 | 学历 | 职务 | | 住址 :n); fflush(stdin); scanf(%s,p-number ); if(!strcmp(p-number ,#) free(p); /释放不需要的构造体内存 break; else +i; scanf(%s%s%s%s%s%s%s,p-name ,p-sex ,p-borth ,p-degree ,p-bus

7、iness ,p-phone ,p-place ); p-con0=0; /防止后面判断出现随机值 if(head=NULL) head=p; else while(q-next !=NULL) /防止完毕后再次输入时出现问题 q=q-next ; q-next =p; q=p; /每次都加在链表尾 return head;/排序函数/输入参数:头指针void Sort(struct Stuff *head) char ch; struct Stuff *p,*q,*r; while(1) printf(请选择排序条件:1.编号2.姓名3.性别4.出生年月5.学历6.职务7. 8.地址0.退出

8、n); scanf( %c,&ch); if(ch=0) break; if(ch8) printf(输入错误,请重新输入!n); continue; p=head; while(p-next!=NULL) /选择排序 q=p-next; r=p; while(q!=NULL) if(Sel(ch,r,q) /调用判断函数 r=q; q=q-next; if(r!=p) /交换内容 Scpy(r-number,p-number); Scpy(r-name,p-name); Scpy(r-sex,p-sex); Scpy(r-borth,p-borth); Scpy(r-degree,p-deg

9、ree); Scpy(r-business,p-business); Scpy(r-phone,p-phone); Scpy(r-place,p-place); p=p-next; Prf(head); /输出/交换函数void Scpy(char *p,char *q) char c50; strcpy(c,p); strcpy(p,q); strcpy(q,c);/判断函数/输出参数:1为真,0为假int Sel(char ch,struct Stuff *p,struct Stuff *q) switch(ch) /实现各个关键字查找 case 1: return strcmp(q-nu

10、mber ,p-number )con ,p-number )=0 ; /排序条件及查找条件 case 2: return strcmp(q-name ,p-name )con ,p-name )=0 ; case 3: return strcmp(q-sex ,p-sex )con ,p-sex )=0 ; case 4: return strcmp(q-borth ,p-borth)con ,p-borth )=0 ; case 5: return strcmp(q-degree ,p-degree )con ,p-degree )=0 ; case 6: return strcmp(q-

11、business ,p-business )con ,p-business)=0 ; case 7: return strcmp(q-phone ,p-phone )con ,p-phone)=0; case 8: return strcmp(q-place ,p-place )con ,p-place )=0; default : exit(0);/查找函数struct Stuff *Ser(struct Stuff *head) struct Stuff *p=NULL,*q,a=0,0,0,0,0,0,0,0; /防止判断时错误 int flag; /查找判断 char ch,sh; q

12、=&a; while(1) printf(请输入要查找的条件:1.编号2.姓名3.性别4.出生年月5.学历6.职务7. 8.住址0.退出n); scanf( %c,&ch); if(ch=0) break; if(ch8) printf(输入错误,请重新输入!n); continue; fflush(stdin); printf(请输入:); gets(q-con ); p=head; /指向表头 flag=0; while(p!=NULL) if(Sel(ch,p,q) printf(员工信息如下:n); printf( 编号 | 姓名 | 性别 | 出生年月 | 学历 | 职务 | | 住

13、址 n%s %s %s %s %s %s %s %sn ,p-number ,p-name ,p-sex ,p-borth ,p-degree ,p-business ,p-phone ,p-place ); printf(是否需要:1.更改 2.删除 3.继续n); scanf( %c,&sh); if(sh=1) Chn(head,p-number); /调用更改函数 else if(sh=2) head=Del(head,p-number); /调用删除函数,得到的head必须return flag=1; break; p=p-next ; if(flag=0) printf(没有找到该

14、员工信息!n); return head;/更改函数/输入参数:n10 为员工编号void Chn(struct Stuff *head,char n10) struct Stuff *p=head; int flag=0; if(head=NULL) printf(未找到员工信息!n); else while(p!=NULL) if(!strcmp(p-number,n) printf(请输入新的信息:n编号|姓名|性别|出生年月|学历|职务| |住址n); scanf(%s%s%s%s%s%s%s%s,p-number ,p-name ,p-sex ,p-borth ,p-degree ,

15、p-business ,p-phone ,p-place ); printf(员工信息如下:n); flag+; break; p=p-next; if(flag=0) printf(未找到该员工信息!n); Prf(head);/删除函数/输入参数:n为员工编号/输出参数:头指针struct Stuff *Del(struct Stuff *head,char n10) struct Stuff *p,*pr; int flag; flag=0; p=head,pr=head; if(head=NULL) printf(未找到员工信息!n); else while(strcmp(p-numb

16、er ,n)&p-next !=NULL) pr=p; p=p-next ; if(!strcmp(p-number ,n) if(p=head) head=p-next ; else pr-next=p-next ; free(p); printf(删除成功!n); i-; else printf(未找到员工信息!n); Prf(head); return head;/输出函数void Prf(struct Stuff *head) struct Stuff *p=head; int i=1; while(p!=NULL) printf(%d. %s %s %s %s %s %s %s %sn ,i+,p-number ,p-name ,p-sex ,p-borth ,p-degree ,p-business ,p-phone ,p-place); p=p-next ;/释放函数void Fre(struct Stuff *head) struct Stuff *p; while(head!=NULL) p=head; head=head-next ; free(p);第 14 页

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 技术资料 > 施工组织

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com