/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
struct ListNode* removeElements(struct ListNode* head, int val){
    if(head == NULL)
        return NULL;
    struct ListNode * newhaed = (struct ListNode *)malloc(sizeof(struct ListNode));   //建立新头
    struct ListNode * cur = newhaed;
    newhaed->next = head;
    while(cur->next != NULL)
    {
        if(cur->next->val == val)
        {
            struct ListNode* temp = cur->next;
            cur->next = cur->next->next;
            free(temp);
        }
        else
            cur = cur->next;
    }
    return newhaed->next;
}