www.pudn.com > LR.rar > status_stack.h
#include#include #define MAX 20 typedef struct{ int stack[MAX]; int top; }status; //³õʼ»¯Õ» void init_stack(status *p) { if( !p) printf("\n³õʼ»¯×´Ì¬Õ»³ö´í!\n"); p->top = -1; } //ѹջ void push(status *p,int x) { if(p->top < MAX-1) { p->top++; p->stack[p->top] = x; } else printf("\n״̬ջÒç³ö!\n"); } //µ¯Õ» int pop(status *p) { int x; if(p->top != 0) { x = p->stack[p->top]; p->top--; return x; } else { printf("\n״̬ջ1¿Õ!\n"); return 0; } } //ȡջ¶¥ÔªËØ int get_top(status *p) { int x; if(p->top != -1) { x = p->stack[p->top]; return x; } else { printf("\n״̬ջ2¿Õ!\n"); return 0; } } //±éÀúÕ»ÔªËØ void out_stack(status *p) { int i; if(p->top <0) printf("\n״̬ջ3¿Õ!\n"); for(i=0; i<=p->top;i++) { printf("%d",p->stack[i]); } }