struct Node { int Data; struct Node* prior; struct Node* next; }; /** * @brief 该函数实现双向链表的建立 * @return 返回双向链表的头指针 * @author wlq_729@163.com * http://blog.csdn.net/rabbit729 * @version 1.0 * @date 2009-03-09 */ Node* CreateDoubleList() { Node* head = new Node; assert(head); head->prior = NULL; head->next = NULL; Node* p = head; int data; bool bIsInput = true; while (bIsInput) { cin>>data; if (0 == data) { bIsInput = false; } else { Node* node = new Node; assert(node); node->Data = data; node->prior = p; node->next = NULL; p->next = node; p = node; } } return head; }
posted on 2009-03-09 21:09 张云临 阅读(130) 评论(0) 编辑 收藏 举报