Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/158.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何在c++; void deleteNodeByKey(int k){ if(head==NULL){ 下一步; 下一步; currentptr=currentptr->next; } } 如果(温度!=NULL){ prevptr->n_C++_Pointers_Visual C++_Singly Linked List - Fatal编程技术网

C++ 如何在c++; void deleteNodeByKey(int k){ if(head==NULL){ 下一步; 下一步; currentptr=currentptr->next; } } 如果(温度!=NULL){ prevptr->n

C++ 如何在c++; void deleteNodeByKey(int k){ if(head==NULL){ 下一步; 下一步; currentptr=currentptr->next; } } 如果(温度!=NULL){ prevptr->n,c++,pointers,visual-c++,singly-linked-list,C++,Pointers,Visual C++,Singly Linked List,如何在c++; void deleteNodeByKey(int k){ if(head==NULL){ 下一步; 下一步; currentptr=currentptr->next; } } 如果(温度!=NULL){ prevptr->next=temp->next; 库特 void deleteNodeByKey(int k) { if (head == NULL) { cout << "Singly Linked List al

如何在c++;
void deleteNodeByKey(int k){
if(head==NULL){
下一步;
下一步;
currentptr=currentptr->next;
}
}
如果(温度!=NULL){
prevptr->next=temp->next;
库特
void deleteNodeByKey(int k) {
    if (head == NULL) {
        cout << "Singly Linked List already Empty. Cant delete" << endl;
    }
    else if (head != NULL) {
        if (head->key == k) {
            head = head->next;
            cout << "Node UNLINKED with keys value : " << k << endl;
        }
        else {
            node* temp = NULL;
            node* prevptr = head;
            node* currentptr = head->next;
            while (currentptr != NULL) {
                if (currentptr->key == k) {
                    temp = currentptr;
                    currentptr = NULL;
                }
                else {
                    prevptr = prevptr->next;
                    currentptr = currentptr->next;
                }
            }
            if (temp != NULL) {
                prevptr->next = temp->next;
                cout << "Node UNLINKED with keys value : " << k << endl;
            }
            else {
                cout << "Node Doesn't exist with key value : " << k << endl;
            }
        }
    }