#include <stdio.h>
#include<stdlib.h>
//链栈的实现
typedef struct Node{
int data;
struct Node *next;
}Node;
Node *top;
Node *in(){
return NULL;
}
int empty(Node *top){
if(!top) return 1;
else return 0;
}
Node *push(Node *top,int x){
Node *s;
s=(Node*)malloc(sizeof(Node));
s->data=x;
s->next=top;
top=s;return top;
}
Node *pop(Node *top){
Node *p;
p=top;
top=top->next;
free(p);
return top;
}
int to(Node *top){
return top->data;
}
int main(){
top=in();
top=push(top,1);
top=push(top,2);
top=push(top,3);
printf("栈顶元素为:%d\n",to(top));
top=pop(top);
printf("移除栈顶元素后,栈顶元素为:%d\n",to(top));
return 0;
}