// 栈的链表实现
#include <cstdio>#include <cstdlib>//#define _OJ_typedef struct Lnode{ int data; struct Lnode *next;} Lnode, *stack;stackcreat_list(stack s){ s = (stack) malloc (sizeof(Lnode)); s->next = NULL;}intisEmpty(stack s){ if(s->next == NULL) return 1; else return 0;}voidpush(int x,stack s){ stack p; p = (stack) malloc (sizeof(Lnode)); p->data = x; p->next = s->next; s->next = p; printf("%d\n", x);}intpop(stack s){ int e; stack p; p = s->next; e = p->data; s->next = p->next; free(p); return e;}int main(int argc, char const *argv[]) { #ifndef _OJ_ //ONLINE_JUDGE freopen("input.txt", "r", stdin);#endif int i, n, x; stack s; s = creat_list(s); printf("empty == %d\n", isEmpty(s)); scanf("%d", &n); for(i = 0;i < n; i++) { scanf("%d", &x); push(x,s); } for(i = 0;i < n; i++) { printf("pop == %d\n", pop(s)); } return 0;}