C语言,链表删除并释放内存问题
data*delet(data*head){intmax=10;intmin=2;data*p,*q,*s;if(head==NULL){printf("NO");exi...
data* delet(data *head)
{
int max=10;
int min=2;
data *p, *q, *s;
if(head == NULL){
printf("NO");
exit (0);
}
p = head;
while(p != NULL){
if(p->n > max || p->n < min){
if(p == head)
head = p->next;
else
q->next = p->next;
s = p;
free(s);
p = p->next;
}
else{
q = p;
p = p->next;
}
}
return(head);
}请问我这个要怎么改? 展开
{
int max=10;
int min=2;
data *p, *q, *s;
if(head == NULL){
printf("NO");
exit (0);
}
p = head;
while(p != NULL){
if(p->n > max || p->n < min){
if(p == head)
head = p->next;
else
q->next = p->next;
s = p;
free(s);
p = p->next;
}
else{
q = p;
p = p->next;
}
}
return(head);
}请问我这个要怎么改? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询