|
Lnode *Delete(Lnode *head,int DelNum) /*这里DelNum作为参数传给Delete函数*/
{
Lnode *p6,*p7;
p6 = NULL;
p7 = NULL;
p6 = (LinkList)malloc(sizeof(Lnode));
p7 = (LinkList)malloc(sizeof(Lnode));
printf("please input the deletenumber:");
scanf("%d",&DelNum); /*这里要scanf干嘛?*/
p6 = head;
if (head == NULL)
{
printf("the list is null\n");
}
else
{
p6 = head;
while (DelNum != p6->data && p6 ->next !=NULL )
{
p7 = p6;
p6 = p6 ->next ;
}
if (DelNum == p6->data )
{
if(p6 == head)
{
head = p6->next ;
}
else
{
p7->next = p6->next ;
}
}
else
{
printf("no this number!\n");
}
}
return head;
} |
|