编辑代码

//元素elem进栈,a为数组,top值为当前栈的栈顶位置
int push(int *a,int top,int elem)
{
    a[++top]=elem;
    return top;
}