#include#define MaxSize 1000 struct stack { int* base; int* top; }; void initStack(struct stack& stack) { stack.base = new int[MaxSize]; if (!stack.base) { return; } stack.top = stack.base; } int getTop(stack& stack) { if (stack.top != stack.base) { return *(stack.top - 1); } else { return -1; } } int getSize(stack& stack) { return (stack.top - stack.base); } bool isEmpty(stack& stack) { return stack.top == stack.base; } bool push(stack& stack, int x) { if (stack.top - stack.base == MaxSize) { return false; } *stack.top = x; stack.top++; return true; } int pop(stack& stack) { int x = 0; if (stack.base == stack.top) { return *stack.top; } else { --stack.top; x = *stack.top; return x; } } void makeEmpty(stack& stack) { if (stack.base) { free(stack.base); stack.base = nullptr; stack.top = nullptr; } } void printStack(stack stack) { int length = getSize(stack); for (int i = 0; i < length; i++) { std::cout << pop(stack) << " "; } } int main() { return 0; }



