我对这个作业和堆栈的数据结构有点困惑。本质上,问题是:
"Give the output printed by java Stack for the input"下面是输入
it was - the best - of times - - - it was - the - -输出将在答案键中
was best times of the was the it (1 left on stack)我不明白你会如何接收这个输出,我试着写我自己的堆栈结构,但是如果我迭代它,我只能得到先进先出。
任何帮助都可以,我将不胜感激。
发布于 2020-03-11 16:23:44
它没有明确说明,但从输入来看,我假设单词被压入堆栈,而-符号是弹出操作。如果是这种情况,则操作为
堆栈推送,堆栈包含it;
was;
it;
the;
it;
it >d23 the,堆栈包含E229,堆栈包含it of,堆栈包含it the of;times;
of;
>E255的<
it >D56>E160it;
it>D65it >,堆栈包含<代码>D66D70,堆栈包含<代码>D71<代码>D72<代码>D73;it;
it the,it it
打印<it>e289it>,堆栈包含<>d90打印,堆栈包含
粗体显示的单词是pop操作的输出。
https://stackoverflow.com/questions/60627619
复制相似问题