题目描述 在栈的顺序存储实现中,将 Top 定义为栈顶元素的下一个位置。请实现这种定义下的入栈和出栈操作。 相关类型定义如下: typedef int Position; typedef struct SNode PtrToSNode; struct SNode { ElementType Data; Position Top; int MaxSize; }; typedef PtrToSNode Stack; 函数接口如下: bool Push(Stack S, ElementType X); ElementType Pop(Stack S); 若栈已满,Push 输出 Stack Full 并返回 false;否则将 X 入栈并返回 true。若栈为空,Pop 输出 Stack Empty 并返回 ERROR;否则返回栈顶元素。 输入格式 第一行输入整数 $N$,表示栈的最大容量。 随后若干行输入操作,操作包括: Push X:将整数 $X$ 入栈。 Pop:弹出栈顶元素。 End:结束操作并输出当前栈中元素。 输出格式 对于非法入栈或出栈,按题目描述输出错误信息。 对于成功的 Pop 操作,输出 X is out,其中 X 为弹出的元素。 遇到 End 后,从栈顶到栈底输出当前栈中元素,整数之间用空格分隔。 输入样例 4 Pop Push 5 Push 4 Push 3 Pop Pop Push 2 Push 1 Push 0 Push 10 End 输出样例 Stack Empty 3 is out 4 is out Stack Full 0 1 2 5