提交 cc9f009b 创建 作者: 宋海霞's avatar 宋海霞

modify

上级 9572a7eb
......@@ -4,19 +4,19 @@
int main(int argc, char* argv[])
{
int i;
DuLinkList* pListHead; // 双向循环链表的表头指针,指向表头节点
DuLinkList* pListNode; // 双向循环链表节点指针
DuLinkList* pListHead; // A pointer to the head of a bidirectional circular list,Points to the header node
DuLinkList* pListNode; // Bidirectional circular list node pointer
DuLinkList* pListHeadTemp;
//
// 初始化双向循环链表的表头节点
// Initializes a pointer to the head node of a bidirectional circular list
//
pListHead = (DuLinkList*)malloc(sizeof(DuLinkList));
pListHead->prior = pListHead;
pListHead->next = pListHead;
//
// 初始化双向循环链表的节点
// Initializes the nodes of a bidirectional circular list
//
for(i=8; i>0; i--)
{
......@@ -30,10 +30,10 @@ int main(int argc, char* argv[])
}
//
// 在第 i 个节点之前插入一个节点
// Insert a node before the ith node
//
InsertBefore(pListHead, 3, 88);
InsertBefore(pListHead, 20, 15); // 插入位置非法.插入失败.
InsertBefore(pListHead, 20, 15); // Invalid insert position. Insert failed.
pListHeadTemp = pListHead;
pListNode = pListHeadTemp->next;
......@@ -45,7 +45,7 @@ int main(int argc, char* argv[])
printf("\n");
//
// 销毁双向循环链表
// Destroy bidirectional circular linked list
//
while(pListHead->next != pListHead)
{
......@@ -62,20 +62,20 @@ int main(int argc, char* argv[])
/*
function:
在第 i 个节点之前插入一个节点.
Insert a node before the ith node.
parameter:
pListHead -- 双向循环链表的表头指针
i -- 插入节点的位置.从 1 开始计数.
Elem -- 插入节点的值.
pListHead -- A pointer to the head of a bidirectional circular list
i -- The location of the insertion node.Count from 1.
Elem -- Insert the value of the node.
returned value:
如果插入成功返回 1
如果插入失败返回 0
Returns 1 if insert succeeds
Returns 0 if insert fails
*/
int InsertBefore(DuLinkList* pListHead, int i, ElemType Elem)
{
DuLinkList* pListNode; // 节点指针
DuLinkList* pListNode; // Node pointer
//
// TODO: Add the code here
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论