#include <bits/stdc++.h>
typedef struct node *pointer;
struct node
{
int Data;
pointer next;
};
typedef pointer stack;
stack Push( stack S, int X ) /* 将元素X压入堆栈S */
{
pointer q;
q = (pointer)malloc(sizeof(struct node));
q->Data = X;
q->next = S->next;
S->next = q;
return S;
}
int Pop(stack S) /* 删除并返回堆栈S的栈顶元素 */
{
pointer first;
int top;
first = S->next;
top = first->Data;
S->next = first->next;
free(first);
return top;
}
stack Createstack() /* 构建一个堆栈的头结点,返回该结点指针 */
{
stack S;
S = (stack)malloc(sizeof(struct node));
S->next = NULL;
return S;
}
int main()
{
return 0;
}
typedef struct node *pointer;
struct node
{
int Data;
pointer next;
};
typedef pointer stack;
stack Push( stack S, int X ) /* 将元素X压入堆栈S */
{
pointer q;
q = (pointer)malloc(sizeof(struct node));
q->Data = X;
q->next = S->next;
S->next = q;
return S;
}
int Pop(stack S) /* 删除并返回堆栈S的栈顶元素 */
{
pointer first;
int top;
first = S->next;
top = first->Data;
S->next = first->next;
free(first);
return top;
}
stack Createstack() /* 构建一个堆栈的头结点,返回该结点指针 */
{
stack S;
S = (stack)malloc(sizeof(struct node));
S->next = NULL;
return S;
}
int main()
{
return 0;
}