public int getElement(Stack<Integer> stack, int position)
{
int result = stack.pop();
if (stack.size() == position)
{
// stack.push(result);
return result;
}else {
int element = getElement(stack, position);
stack.push(element);
return element;
}
}
获取栈中任意位置的元素
最新推荐文章于 2022-04-18 23:09:34 发布