编辑代码

#include <stdio.h>
#define Maxsize 10
typedef struct{
    int data[10];
    int top;
} SqStack;

void InitStack(SqStack &S){
    S.top = -1;
}

bool Push(SqStack &S, int x){
    if(S.top == Maxsize-1)
         return false;
    S.top = S.top +1;
    S.data[S.top] = x;
    return true;
}

bool Pop(SqStack &S, int &x){
    if(S.top ==-1)
         return false;
    x = S.data[S.top];
    S.top = S.top -1;
    return true;
}

bool GetTop(SqStack S, int &x){
    if(S.top ==-1)
         return false;
    x = S.data[S.top];
    return true;
}

void testStack(){
    SqStack S;
    InitStack(S);
}