#include
#include
#include
struct nod{
int num;
struct nod *next;
};
typedef struct nod node;
node* create()
{
node* stack;
stack=(node*)malloc(sizeof(node));
stack->next=NULL;
return(stack);
}
int push(int n,node* s)
{
node* tmp=NULL;
tmp = (node*)malloc(sizeof(node));
tmp->next=s->next;
s->next=tmp;
tmp->num=n;
return 0;
}
int pop(node* s)
{
node sr;
int n ;
n=s->next->num; //取出来的不是栈顶的元素值啊,要是栈顶就一直是0啊
sr=s->next;
s->next=s->next->next;
free(sr);
return n;
}
int main()
{
node st;
int sn;
st = create();
push(5,st);
push(5,st);
sn = pop(st);
printf("%d\n",sn);
return 0;
}