删除Ith元素

void removeIelement(Dlist& d, int i) {
    if (d.head == NULL) {
        cout << "EMPTY" << endl;
        return;
    }
    else {
        int count = 1;
        Node* cur = d.head;
        while (cur != NULL) {
            if (count == i) {
                Node* temp = cur->next;
                Node* temp2 = temp->next;
                cur->next = temp->next;
                temp2->prev = cur;
            }
            count++;           
            cur = cur->next;
        }
    }
}

这是我的代码删除双链表中的节点

我的双向链接列表是:

1 2 3 4 5 6 7 8 9 10

但是,当我运行该程序时,如果输入i = 1,它将删除

 1 3 4 5 6 7 8 9 10

与i = 2 ...相同..它将在元素i(i + 1)之后删除

1 2 4 5 6 7 8 9 10

您能帮我解决此功能吗?谢谢