有雙向循環鏈表結點定義為
struct node
{ int data;
struct node *front
};
有兩個雙向循環鏈表A
BOOL DeteleNode(Node *pHeader
{
if (pHeader == NULL) return;
BOOL bRet = FALSE;
Node *pNode = pHead;
while (pNode != NULL)
{
if (pNode
{
if (pNode
{
pHeader = pNode
pHeader
}
else
{
if (pNode
{
pNode
}
pNode
}
Node *pNextNode = pNode
delete pNode;
pNode = pNextNode;
bRet = TRUE;
//不要break或return
}
else
{
pNode = pNode
}
}
return bRet;
}
void DE(Node *pHeadA
{
if (pHeadA == NULL || pHeadB == NULL)
{
return;
}
Node *pNode = pHeadA;
while (pNode != NULL)
{
if (DeteleNode(pHeadB
{
if (pNode
{
pHeadA = pNode
pHeadA
}
else
{
pNode
if (pNode
{
pNode
}
}
Node *pNextNode = pNode
delete pNode;
pNode = pNextNode;
}
else
{
pNode = pNode
}
}
}
From:http://tw.wingwit.com/Article/program/sjjg/201405/30940.html