print?Node *create()
{
int n = 20;
Node *pNew, *pTail, *pHead;
pHead = (Node *)malloc(sizeof(Node));
pHead->next = pHead;//空鏈表 自己指向自己
pTail = pHead; //pTail指針指向pHead節點
for(int i = 1; i <= n; i++)
{
pNew = (Node *)malloc(sizeof(Node));
if(pNew == NULL)
{
printf("error!!");
exit(0);
}
pNew->data = i;
if(pHead->next == pHead)//此時為空鏈表
{
pHead->next = pNew;
pTail = pNew; //pTail指向新添加的那個節點
}else{//不是空表的時候
pTail->next = pNew;
pTail = pNew;
}
}
pTail->next = pHead;//添加完以後把尾指針的指針域指向頭節點
return pTail;
}
Node *create()
{
int n = 20;
Node *pNew, *pTail, *pHead;
pHead = (Node *)malloc(sizeof(Node));
pHead->next = pHead;//空鏈表 自己指向自己
pTail = pHead; //pTail指針指向pHead節點
for(int i = 1; i <= n; i++)
{
pNew = (Node *)malloc(sizeof(Node));
if(pNew == NULL)
{
printf("error!!");
exit(0);
}
pNew->data = i;
if(pHead->next == pHead)//此時為空鏈表
{
pHead->next = pNew;
pTail = pNew; //pTail指向新添加的那個節點
}else{//不是空表的時候
pTail->next = pNew;
pTail = pNew;
}
}
pTail->next = pHead;//添加完以後把尾指針的指針域指向頭節點
return pTail;
}