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