diff --git "a/2224020152/\347\254\254\344\270\211\345\215\225\345\205\203/\345\256\236\347\216\260\351\241\272\345\272\217\346\240\210\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\351\241\272\345\272\217\346\240\210\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..a3eb2c2a77bc6c701d35f24c772cb89b5f2c4888 --- /dev/null +++ "b/2224020152/\347\254\254\344\270\211\345\215\225\345\205\203/\345\256\236\347\216\260\351\241\272\345\272\217\346\240\210\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,49 @@ +#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