#include<stdlib.h>
 #include<stdio.h>
 #define MaxSize 10
 #define Elemtype int
1.栈的基本概念

2.栈的基本操作
typedef struct
 {
     Elemtype data[MaxSize];
     int top;
}Sqstack;
//初始化栈
 void InitStack(Sqstack& S)
 {
     S.top = -1;   //初始化栈顶指针
 }
 bool StackEmpty(Sqstack S)
 {
     if (S.top == -1)
         return true;
     else
         return false;
 }
 void testStack()
 {
     Sqstack S;   //声明一个顺序栈(分配空间)
     InitStack(S);
    //。。。。后续操作
 }
//新元素进栈
 bool Push(Sqstack& S, Elemtype x)
 {
     if (S.top == MaxSize - 1)
         return false;
    //S.top = S.top + 1;
     //S.data[S.top] = x;
     //也可以写成
     S.data[++S.top] = x;
 }
//出栈操作
 bool Push(Sqstack& S, Elemtype &x)
 {
     if (S.top == - 1)
         return false;
    //x = S.data[S.top] ;
     //S.top = S.top - 1;
     //也可以写成
     x = S.data[S.top--];  //先出栈,指针再减一
 }
//读栈操作
 bool GetTop(Sqstack S, Elemtype& x)
 {
     if (S.top == -1)
         return false;
     x = S.data[S.top]; //x记录栈顶元素
     return true;
 }
//****做题的时候一定要注意top指针指向的位置,看看是指向栈顶元素还是指向栈顶元素后面一个位置****/
//共享栈
 typedef struct
 {
     Elemtype data[MaxSize]; //静态数组存放栈中元素
     int top0;               //0号栈栈顶指针
    int top1;               //1号栈栈顶指针
 }Shstack;
//初始化栈
 void InitStack(Shstack& S)
 {
     S.top0= -1;   //初始化栈顶指针
     S.top1 = MaxSize;
 }

3.链栈的定义
//链栈
 typedef struct Linknode
 {
     Elemtype data; //数据域
     struct Linknode* next;
 }*Listack;
//进栈和出栈都只能在栈顶一端进行(链头作为栈顶)
