明天就要交作业了,可是还有三个错,求大
#include<stdio.h>#include<stdlib.h>
#include<malloc.h>
#define NULL 0
#define LEN sizeof(struct worker)
struct worker
{
long num;
char name[20];
float pay;
long age;
struct worker *next;
};
/***************创建链表***********************/
struct worker *creat(struct worker *head,int n)
{
struct worker *p1,*p2;
int i;
head=NULL;
for(i=0;i<n;i++)
{
p1=(struct worker*)malloc(LEN);
printf("num name pay age \n");
scanf("%d",&p1->num);
gets(p1->name);
scanf("%f",&p1->pay);
scanf("%d",&p1->age);
p1->next=NULL;
if(head==NULL)
head=p1;
else
{
p2->next=p1;
}
p2=p1;
}
return head;
}
/***************输出链表***********************/
void output(struct worker *head)
{
struct worker *p;
p=head;
printf("num name pay age \n");
while(p!=NULL)
{
printf("%d,%s,%f,%d \n",p->num,p->name,p->pay,p->age);
p=p->next;
}
}
/****************添加节点**********************/
struct worker *insert (struct worker *head)
{
struct worker *p1,*p2,*p3;
p1=head;
p3=(struct worker*)malloc(LEN);
printf("num name pay age \n");
scanf("%d",&p3->num);
gets(p3->name);
scanf("%f",&p3->pay);
scanf("%d",&p3->age);
p3->next=NULL;
if(head==NULL)
{
head=p3;
p3->next=NULL;
}
else
{
while((p1->pay)>(p3->pay))
{p2=p1;
p1=p1->next;
}
if((p1->pay)<(p3->pay))
if(head==p1)
{
head=p3;
p3->next=p1;
}
else
{
p2->next=p3;
p3->next=p1;
}
else
{
if (p1->next=NULL)
{p1->next=p3;
p3->next=NULL;
}
}
}
/****************删除节点**********************/
struct worker *delet(struct worker *head)
{
struct worker *p1,*p2;
int n;
p1=head;
if(head==NULL)
printf("\n 链表为空\n");
else
{printf("\n 请输入要删除的职工号\n");
scanf("%d",&n);
while (strcmp(p1->num,n)!=0 && p1->next!=NULL)
{
p2=p1;
p1=p1->next;
}
if(strcmp(p1->num P蘆