ATEM0那个方法确实可以不用定义currentNodeBefore,但是你有没有想过这样就无法delete需要删除的node了?
2019-03-13
Node *currentNode=m_pList;
Node *currentNodeBefore=nullptr;
for(int a=0;a<i;a++)
currentNode=currentNode->next;
currentNodeBefore=currentNode;
currentNode=currentNode->next;
currentNodeBefore->next=currentNode->next;
pNode->data=currentNode->data;
这么写是一种更高效的循环。
Node *currentNodeBefore=nullptr;
for(int a=0;a<i;a++)
currentNode=currentNode->next;
currentNodeBefore=currentNode;
currentNode=currentNode->next;
currentNodeBefore->next=currentNode->next;
pNode->data=currentNode->data;
这么写是一种更高效的循环。
2018-12-23
void DeleteContact(List *pList)
{
Node node;
Person person;
cout << "Please input name:" << endl;
cin >> person.name;
cout << "Please input phone number:" << endl;
cin >> person.phone;
node.data = person;
int num = 0;
num = pList->LocatedElem(&node);
pList->ListDelete(num, &node);
}
{
Node node;
Person person;
cout << "Please input name:" << endl;
cin >> person.name;
cout << "Please input phone number:" << endl;
cin >> person.phone;
node.data = person;
int num = 0;
num = pList->LocatedElem(&node);
pList->ListDelete(num, &node);
}
2018-12-18
后面应该不用加m-pList->next = NULL吧,它的currentNode等于m-pList->next已经被释放掉了啊
2018-11-04
current Node before可以不用定义,直接用current Node-> next= currentNode -> next-> next
2018-08-13