/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
struct ListNode* removeElements(struct ListNode* head, int val) {
struct ListNode *dummy=(struct ListNode *)malloc(sizeof(struct ListNode));
dummy->next=head;
struct ListNode *pre=dummy;
// struct ListNode *Next=NULL;
struct ListNode *cur=head;
while(cur)
{
// Next=cur->next;
if(cur->val == val)
{
pre->next=cur->next; //跳过相同节点
}
else
{
pre=cur;
}
cur=cur->next; //向后移一个
}
return dummy->next;
}