堆叠、推送和弹出。例如,火星mips

堆叠、推送和弹出。例如,火星mips,mips,Mips,字母表示推入,星号表示从最初的空堆栈中弹出。假设 执行以下操作顺序。绘制每个步骤的堆栈内容, 然后给出弹出的值的顺序。 V E R*Y E**A S**Y*** 现在我的同学们得到的最终答案是: REYSAYEV和我试过了,我得到了一些不同的东西既然机器可以做,为什么还要用手做呢 请在上尝试此Python代码 你的同学似乎是对的;示例输出: Current stack: ['V'] Current stack: ['V', 'E'] Current stack: ['V', 'E', 'R

字母表示推入,星号表示从最初的空堆栈中弹出。假设 执行以下操作顺序。绘制每个步骤的堆栈内容, 然后给出弹出的值的顺序。 V E R*Y E**A S**Y***

现在我的同学们得到的最终答案是:


REYSAYEV和我试过了,我得到了一些不同的东西

既然机器可以做,为什么还要用手做呢

请在上尝试此Python代码

你的同学似乎是对的;示例输出:

Current stack:  ['V']
Current stack:  ['V', 'E']
Current stack:  ['V', 'E', 'R']
Output: R
Current stack:  ['V', 'E']
Current stack:  ['V', 'E', 'Y']
Current stack:  ['V', 'E', 'Y', 'E']
Output: E
Current stack:  ['V', 'E', 'Y']
Output: Y
Current stack:  ['V', 'E']
Current stack:  ['V', 'E', 'A']
Current stack:  ['V', 'E', 'A', 'S']
Output: S
Current stack:  ['V', 'E', 'A']
Output: A
Current stack:  ['V', 'E']
Current stack:  ['V', 'E', 'Y']
Output: Y
Current stack:  ['V', 'E']
Output: E
Current stack:  ['V']
Output: V
Current stack:  []
=> None

你得到了什么?以下是通过以下方式完成的工作:

Stack: VER
Operation: POP
Resultant Stack: VE
Pops: R

Stack: VE
Operation: PUSH Y
Resultant Stack: VEY
Pops: R

Stack: VEY
Operation: PUSH E
Resultant Stack: VEYE
Pops: R

Stack: VEYE
Operation: POP
Resultant Stack: VEY
Pops: RE

Stack: VEY
Operation: POP
Resultant Stack: VE
Pops: REY

诸如此类。

我该如何在MIPS中写入此内容?我不知道;我从问题中假设你应该手工绘制堆栈,这更像是一个“通过堆栈所做的步骤”的问题,而不是一个MIPS编程问题。哇,好吧,现在我开始在这里获得一些直觉。对于第一个,你去掉了R,这样你就有了EY的空间,对吗?谢谢你,这开始更有意义了!另一个问题:当前堆栈:['V','E','A']为什么不是['V','E','A','Y']?我得到了这样的结果Reysavy,你为什么要弹出R?我弹出R是因为A*紧跟其后。你的答案很接近,我建议你从头开始尝试。也许你只是犯了个错误
Stack: VER
Operation: POP
Resultant Stack: VE
Pops: R

Stack: VE
Operation: PUSH Y
Resultant Stack: VEY
Pops: R

Stack: VEY
Operation: PUSH E
Resultant Stack: VEYE
Pops: R

Stack: VEYE
Operation: POP
Resultant Stack: VEY
Pops: RE

Stack: VEY
Operation: POP
Resultant Stack: VE
Pops: REY