还没优化,也就是栈满动态申请内存
#include<cstdio> #include<cstdlib> #include<cstring> #define MAXSIZE 100 typedef struct{ int data[MAXSIZE]; int top; }SqStack; int Push(SqStack *S,int e){ //压栈操作 if(S->top == MAXSIZE - 1) return 0; S->top++; S->data[S->top] = e; return 1; } int Pop(SqStack *S,int *e){ //出栈操作 if(S->top == -1) return 0; *e = S->data[S->top]; S->top--; return 1; } int main(){ return 0; }
时间: 2024-10-14 05:48:11