链栈
链栈 1 #include<stdio.h> 2 #include<malloc.h> 3 #include<stdlib.h> 4 5 typedef struct Node 6 { 7 int data; 8 struct Node * pNext; 9 }NODE, *PNODE; 10 11 typedef struct Stack 12 { 13 PNODE pTop; //top指针 14 PNODE pBottom; //bottom指针 15 }STACK, *PSTACK; 16 17 void init(PSTACK); 18 void push(PSTACK,int); 19 void traverse(PSTACK); 20 bool is_empty(PSTACK); 21 bool pop(PSTACK,int*); 22 void clear(PSTACK); 23 24 int main() 25 { 26 STACK S; //STACK 等价于struct Stack 27 int val; 28 29 init(&S); //目的是造出一个空栈 30 printf("入栈元素是"); 31 push(&S,1); //压栈 32 push(&S,2); 33 push(&S,3); 34 push(&S,4); 35 push(&S,5);