资源描述:
《c-语言课程设计-超市员工管理系统.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#include#include#include//清屏函数头文件#includestructStuff{charnumber[10];//员工编号charname[10];//员工姓名charsex[8];//员工性别charborth[10];//员工生日chardegree[20];//员工学历charbusiness[20];//员工职务charphone[15];//员工电话charplace[50];//员工住址charcon[50];//判断关键字专用st
2、ructStuff*next;};charMenu(void);//菜单显示structStuff*App(structStuff*head);//添加voidSort(structStuff*head);//排序structStuff*Ser(structStuff*head);//查找voidChn(structStuff*head,charn[10]);//更改voidScpy(char*p,char*q);//排序中用于交换员工信息structStuff*Del(structStuff*head,charn[10]);//删除intSel(
3、charch,structStuff*p,structStuff*q);//判断排序及关键字专用函数voidPrf(structStuff*head);//输出voidFre(structStuff*head);//释放inti=1;//定义全局变量,实现实时员工人数统计intmain(void){charn[10];structStuff*head=NULL;//链表头指针定义while(1){switch(Menu()){case'1':printf("请输入员工信息,直接输入'#'结束");head=App(head);break;cas
4、e'2':Sort(head);break;case'3':head=Ser(head);break;case'4':printf("员工信息如下:");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!");exit(0);default:printf("输入错误
5、,请重新输入!");}fflush(stdin);//清楚缓冲区printf("按任意键继续~");getchar();system("cls");//清屏效果}Fre(head);return0;}//菜单函数charMenu(void){charch;printf("------------请选择-----------");printf("1.添加员工信息2.员工信息排序3.查找员工信息4.输出员工信息5.更改员工信息6.删除员工信息0.退出-----------------------------");
6、scanf("%c",&ch);returnch;}//添加成员函数//输入参数:链表头指针//返回参数:链表头指针structStuff*App(structStuff*head){structStuff*p=NULL,*q=head;while(i){p=(structStuff*)malloc(sizeof(structStuff));//申请结构体空间if(p==NULL){printf("内存不够!");exit(0);}p->next=NULL;//指针域为空printf("请输入第%d名员工:",i);printf("编号
7、姓
8、名
9、性别
10、出生年月
11、学历
12、职务
13、电话
14、住址:");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->business,p->phone,p->place);p->con[0]=' ';//防止后面判断出现随机值if(head==NULL)head=p;else{while(q-
15、>next!=NULL)//防止结束后再次输入时出现问题q=q->next;q->next=p;}q=p;//每次都加在链