自定义一个删除函数和一个插入函数。我给你提供一个思路:
struct student
{int number;
struct student* next;
}
struct student
*delete(struct student
*head,int num)
{......
if (p->next指向你要删的结点){q=p->next ;p->next=p->next->next; free(q);}
......
return(head);
}
struct student
*insert(struct student
*head,int num)
{struct student *p,*new;
p=head; //假设链表有头结点
while(p->number!=num-1)
{if(p->next!=NULL) p=p->next;
else break;
}
new=(struct student
* )malloc(sizeof(struct student));
new->next=p->next;
p->next=new;
......
return(head);
}
[此贴子已经被作者于2004-12-30 14:49:32编辑过]