遍历堆栈 [英] traversing a stack

查看:144
本文介绍了遍历堆栈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们知道数据可以被压入堆栈或弹出4m。可以遍历
堆栈吗?

We kno that data can be pushed onto the stack or popped 4m it. Can
stack be traversed ??

推荐答案

asit写道:
asit wrote:

我们知道数据可以被压入堆栈或弹出4m。可以遍历
堆栈吗?
We kno that data can be pushed onto the stack or popped 4m it. Can
stack be traversed ??



C3rt41n1y。

C3rt41n1y.


asit写道,On 01/12/07 15:01:
asit wrote, On 01/12/07 15:01:

我们知道数据可以被压入堆栈或弹出4m。
We kno that data can be pushed onto the stack or popped 4m it.



我们吗?无论如何都会是哪一堆?返回地址堆栈是否为处理器或使用正常索引

寄存器实现的堆栈构建了?b $ b?或者可能是在C中实现为数据结构的堆栈?

Do we? Which stack would that be anyway? The return address stack built
in to the processor or a stack implemented using one of the normal index
registers? Or possibly a stack implemented as a data structure in C?


可以

堆栈被遍历?
Can
stack be traversed ??



如果你的C实现使用一个堆栈用于自动变量和/或返回

地址(并非所有人都这样做,尽管他们使用的是实现

类似的语义)然后答案是它取决于,但不是在便携式C.

如果你的意思是用C实现的堆栈数据结构那么答案是

取决于。

-

Flash Gordon

If your C implementation uses a stack for auto variables and/or return
addresses (which not all do, although they use something that implements
similar semantics) then the answer is it depends, but not in portable C.
If you mean a stack data structure implemented in C then the answer is
it depends.
--
Flash Gordon


12月1日,8:01 pm,asit< lipu ... @ gmail.comwrote:
On Dec 1, 8:01 pm, asit <lipu...@gmail.comwrote:

我们知道数据可以被推入堆栈或弹出4m。可以遍历
堆栈吗?
We kno that data can be pushed onto the stack or popped 4m it. Can
stack be traversed ??



是否可以遍历堆栈无论是静态还是动态内存

分配

如果它是静态的使用数组的实现然后它可以遍历

简单地循环,如数组

或者如果它在动态或链表重复表示它可以是
通过设置指向顶部的指针遍历
,然后遍历地址

的下一个指针直到其为空

yes stack can be traversed whether it is in static or dynamic memory
allocation
if it is static implementation using arrays then it can be traversed
by simply for loop as in case of arrays
or if it is in dynamic or linked list repesentation it can be
traversed by setting a pointer to the top and then traversing address
of the next pointer until its null


这篇关于遍历堆栈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆