// 结点结构体
struct Node {
int val;
Node* next;
Node() : val(0), next(nullptr) {}
Node(int x) : val(x), next(nullptr) {}
Node(int x, Node *next) : val(x), next(next) {}
};
Node* removeElements(Node* head, int val) {
Node dummy(0, head); // 哑结点,统一处理头结点
Node* cur = &dummy;
while (cur->next) {
if (cur->next->val == val) {
_______________________ // 在此填入代码
}
else {
cur = cur->next;
}
}
return dummy.next;
}