原链删除需要考虑头结点状况
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
struct ListNode* removeElements(struct ListNode* head, int val){
struct ListNode *v_head;
v_head =(struct ListNode *) malloc(sizeof(struct ListNode));
v_head->next=head;
struct ListNode *p=v_head;
while(p->next!=NULL)
{
if(p->next->val==val)
{
p->next = p->next->next;
}
else p=p->next;
}
return v_head->next;
}