1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
   | #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #define MAX 10 typedef struct SqStack { 	int data[MAX]; 	int top; }SqStack;
  bool InitStack(SqStack* q) { 	q->top = -1; 	return true; }
  bool StackEmpty(SqStack* q) { 	if (q->top == -1) 		return true; 	else 		return false; }
  bool StackFull(SqStack* q) { 	if (q->top == MAX - 1) 		return true; 	else 		return false; }
  bool Push(SqStack* q, int num) { 	if (q->top==MAX-1) 	{ 		return false; 	} 	q->data[++q->top]= num; 	return true; }
  bool Pop(SqStack* q, int *num) { 	if (q->top == -1) 	{ 		return false; 	} 	*num=q->data[q->top--]; 	return true; }
  bool GetTop(SqStack* q, int* num) { 	if (q->top == -1) 	{ 		return false; 	} 	*num = q->data[q->top]; 	return true; }
   |