若一个栈以向量v[1..n]存储,且空栈的栈顶指针top为n+1,则将元素x入栈的正确操作是A.top = top+1; V[top] = x; \x05\x05B.V[top] = x; top = top+1; C.top = top-1; V[top] = x; \x05\x05D.V[top] = x; top = top-1;为什么不是A啊?T

来源:学生作业帮助网 编辑:六六作业网 时间:2024/05/30 18:43:23
若一个栈以向量v[1..n]存储,且空栈的栈顶指针top为n+1,则将元素x入栈的正确操作是A.top=top+1;V[top]=x;\x05\x05B.V[top]=x;top=top+1;C.to

若一个栈以向量v[1..n]存储,且空栈的栈顶指针top为n+1,则将元素x入栈的正确操作是A.top = top+1; V[top] = x; \x05\x05B.V[top] = x; top = top+1; C.top = top-1; V[top] = x; \x05\x05D.V[top] = x; top = top-1;为什么不是A啊?T
若一个栈以向量v[1..n]存储,且空栈的栈顶指针top为n+1,则将元素x入栈的正确操作是
A.top = top+1; V[top] = x; \x05\x05B.V[top] = x; top = top+1;
C.top = top-1; V[top] = x; \x05\x05D.V[top] = x; top = top-1;
为什么不是A啊?TOP不是应该往上吗?

若一个栈以向量v[1..n]存储,且空栈的栈顶指针top为n+1,则将元素x入栈的正确操作是A.top = top+1; V[top] = x; \x05\x05B.V[top] = x; top = top+1; C.top = top-1; V[top] = x; \x05\x05D.V[top] = x; top = top-1;为什么不是A啊?T
C 啊,现在空栈是指针在最大下标以上,自然是进栈就需要往下减,并且合法下标只是1..n