/** * @brief 链式栈的表示与实现 * @author wlq_729@163.com * http://blog.youkuaiyun.com/rabbit729 * @version 1.0 * @date 2009-03-10 */ #include <assert.h> #include <iostream> using namespace std; struct Node { int Data; struct Node* next; }; /** * @brief 初始化栈 * @return 返回栈头指针 */ Node* InitStack() { Node* head = new Node; assert(head); head->next = NULL; return head; } /** * @brief 链式栈的建立 * @return 返回链式栈的头指针 */ Node* CreateLinkStack() { Node* head = new Node; assert(head); head->next = NULL; Node* p = head; int data = 0; bool bInPuts = true; while (bInPuts) { cin>>data; if (0 == data) { bInPuts = false; } else { Node* node = new Node; assert(node); node->Data = data; node->next = p->next; p->next = node; } } return head; } /** * @brief 元素e入栈 * @param[in] head 栈头指针 * @