diff --git "a/2224020152/\347\254\254\344\270\211\345\215\225\345\205\203/\345\256\236\347\216\260\347\216\257\345\275\242\351\230\237\345\210\227\347\232\204\345\220\204\347\247\215\345\237\272\346\234\254\350\277\220\347\256\227\347\232\204\347\256\227\346\263\225.cpp" "b/2224020152/\347\254\254\344\270\211\345\215\225\345\205\203/\345\256\236\347\216\260\347\216\257\345\275\242\351\230\237\345\210\227\347\232\204\345\220\204\347\247\215\345\237\272\346\234\254\350\277\220\347\256\227\347\232\204\347\256\227\346\263\225.cpp" new file mode 100644 index 0000000000000000000000000000000000000000..957d6db91cad3ad451fa670526fff46cbbfbb2ba --- /dev/null +++ "b/2224020152/\347\254\254\344\270\211\345\215\225\345\205\203/\345\256\236\347\216\260\347\216\257\345\275\242\351\230\237\345\210\227\347\232\204\345\220\204\347\247\215\345\237\272\346\234\254\350\277\220\347\256\227\347\232\204\347\256\227\346\263\225.cpp" @@ -0,0 +1,50 @@ +#include +#include +#define MaxSize 50 +typedef int ElemType; +typedef struct{ +    ElemType data[MaxSize];           +    int top;                 +}SqStack;  + + +void InitStack(SqStack *&s){ +    s=(SqStack *)malloc(sizeof(SqStack)); +    s->top = -1;          +} + + +void DestroyStack(SqStack *&s){ +    free(s); +}  + + +bool StackEmpty(SqStack *s){ +    return(s->top == -1);     +}  + + +bool Push(SqStack *&s,ElemType e){ +    if(s -> top == MaxSize -1)         +        return false; +    s->top++;                  +    s->data[s->top] = e;         +    return true; +}  + + +bool Pop(SqStack *&s,ElemType &e){ +    if(s->top == -1) +        return false; +    e=s->data[s->top];         +    s->top--;                 +    return true; +}  + + +bool GetTop(SqStack * s,ElemType &e){ +    if(s->top == -1) +        return false; +    e=s->data[s->top];             +    return true;             +} \ No newline at end of file