64,639
社区成员
发帖
与我相关
我的任务
分享
void Delete(Node *head)
{
Node *temp=head;
Node *pNext=NULL;
if (temp==NULL)
{
cout<<"No head!"<<endl;
return;
}
while (temp!=NULL)
{
pNext=temp;
temp=temp->next;
delete pNext;
pNext=NULL;
}
}
void Print(Node* head)
{
if(head==NULL)
{
cout<<"No Head!"<<endl;
return;
}
Node *temp=head->next;
if (temp==NULL)
{
cout<<"空表"<<endl;
return;
}
while (temp!=NULL)
{
cout<<temp->number<<" ";
temp=temp->next;
}
cout<<endl;
}
void Delete(Node *&head)
{
Node *cur = NULL;
if (head == NULL)
{
cout<<"No head!"<<endl;
return;
}
while (head != NULL)
{
cur = head;
head = head->next;
delete cur;
}
}
while (temp!=NULL)
{
pNext=temp;
temp=temp->next;
delete pNext;
pNext=NULL;
}