void insertList()
{
Node* temp = new Node();
cin >> temp -> data;
pHead -> pLast = temp;
temp -> Next = pHead;
temp -> pList = NULL;
pHead = temp;
}
void sortList() //冒泡排序
{
Node * p=new Node();
Node * q=new Node();
int temp;
for(p=pHead->pNext;p->pNext!=NULL;p=p->pNext)
{
for(q=p->pNext;q!=NULL;q=q->pNext)
{
if(q->data<p->data)
{
temp=q->data;
q->data=p->data;
p->data=temp;
}
}
}
}
void deleteList(int position) //删除指定位置的节点
{
Node * p=pHead->pNext;
if(position>length||position<=0)
{
cout<<"over stack !"<<endl;
return;
}
for(int i=0;i<position-1;i++)
{
p=p->pNext;
}
p->pLast->pNext=p->pNext;
p->pNext->pLast=p->pLast;
delete p;
length--;
}
C++.编程题.删除双链表
最新推荐文章于 2022-10-03 11:12:19 发布