该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
STUDENT *init()
{
return NULL;
}
/*创建链表*/
STUDENT *create()
{
STUDENT *h=NULL,*info; /* STUDENT指向结构体的指针*/
for(;;)
{
info=(STUDENT *)malloc(sizeof(STUDENT)); /*申请空间*/
if(!info) /*如果指针info为空*/
{
printf("\nout of memory"); /*输出内存溢出*/
return NULL; /*返回空指针*/
}
printf("\nPlease shuru number:");
gets(info.no);
printf("Please shuru name:");
gets(info.name);
printf("Please shuru sex:");
gets(info.sex) ;
printf("\nPlease shuru buming:");
gets(info.buming);
printf("\nPlease shuru name:");
gets(data.name);
printf("Please shuru homenumber:");
gets(info.homenumber);
printf("\nPlease shuru ipnumber:");
gets(info.ipnumber);
printf("\nPlease shuru idnumber:");
gets(info.idnumber);
printf(“\nPlease shuru income:”);
gets(info.income);
printf(“\nPlease shuru age:”);
gets(info.age);
info->next=h; /*将头结点做为新输入结点的后继结点*/
h=info; /*新输入结点为新的头结点*/
}
return(h); /*返回头指针*/
}
/*输出链表中结点信息*/
void print(STUDENT *h)
{
int i=0; /* 统计记录条数*/
STUDENT *p; /*移动指针*/
clrscr(); /*清屏*/
p=h; /*初值为头指针*/
printf("\n\n\n****************************STUDENT********************************\n");
printf("|rec|nO | name | bum| income| homnum| celnum | sex|\n");
printf("|---|----------|---------------|----|----|----|--------|-------|\n");
while(p!=NULL)
{
i++;
printf("|%3d |%-10s|%-15s|%4d|%4d|%4d| %4.2f | %4.2f | %3d |\n", i, p->no,p->name,p->buming,p->income,
p->homenumber,p->ipnumber,p->sex);
p=p->next;
}
printf("**********************************end*********************************\n");
}
/* 添加一个职工的信息 */
void AddHead (struct employee* head, char name [50], char num [10], char sex,char edu[10],char duty[15], int age, int income) /*增加职工信息*/
{
struct employee * p, *q = head;
while (q->next != NULL)
q = q->next;
p = (struct employee* )malloc(sizeof(employee));
strcpy(p->name, name);
strcpy(p->num, num);
p->sex = sex;
strcpy(p->edu, edu);
strcpy(p->duty, duty);
p->age = age;
p->income = income;
p->next = NULL;
q->next = p;
}