1 / 20
学 号 09710219
数据结构课程设计
设计说明书
员工管理系统
起止日期: 2012年 1 月 2 日 至 2012 年 1 月 6 日
学生姓名
孙uct Stuff *head); //输出
void Fre(struct Stuff *head); //释放
int i=1; //定义全局变量,实现实时员工人数统计
5 / 20
int main(void)
{
char n[10];
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("员工信息如下:\n");
Prf(head);
break;
case '5':
printf("请输入员工编号:");
scanf("%s",n);
Chn(head,n);
break;
case '6':
printf("请输入员工编号:");
6 / 20
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);
return 0;
}
//菜单函数
char Menu(void)
{
char ch;
printf("------------请选择-----------\n");
printf("\n2.员工信息排序\n3.查找员工信息\\\n6.删除员工信息\n0.退出\n-----------------------------\n");
scanf(" %c",&ch);
return ch;
}
8 / 20
//添加成员函数
//输入参数:链表头指针
//返回参数:链表头指针
struct Stuff *App(struct Stuff *head)
{
struct Stuff *p=NULL,*q=head;
while(i)
{
p=(struct Stuff *)malloc(sizeof(struct Stuff)); //申请结构体空间
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->business ,p->phone ,p->place );
8 / 20
p->con[0]='\0'; //防止后面判断出现随机值
if(head==NULL)
head=p;
else
{
while(q->next
员工管理系统-数据结构 来自淘豆网m.daumloan.com转载请标明出处.