Home > Back-end >  Of new help!
Of new help!

Time:10-04

For a stack, the use of stored in order, if the stack pointer when the initialization top as 0,
So when do stack operation, should be
Data [top++]=x
The stack should be
Gettop=data [-- top]
This way is correct?
Why can I see a book is like this
O bosses give advice or comments!

CodePudding user response:

This watch your own idea design, you can design as the first one is 0, can be designed into the first one is 1, LUA is such

CodePudding user response:

If, as written in the book, then the stack [0] don't store any data, is directly from the stack [1] is beginning to store

CodePudding user response:

Or that sentence, the design of the interface is provided to outside you bool push (data), bool pop (data), external index, zha operation can be as long as you don't go wrong

CodePudding user response:

reference 1st floor ggglivw response:
this watch your own idea design, you can design as the first one is 0, can be designed into the first one is 1, LUA is

But if, in accordance with the written book, the storage should be started with stack [1], this stack [0] is vacant

CodePudding user response:

Empty is empty, the LUA is also the first began

CodePudding user response:

Sometimes do special design with an empty, with special USES, such as table, how to know the end, with the first useless,

CodePudding user response:

To see your stack top initial cost is 0 or 1;

CodePudding user response:

Yes, one more words will make the code judgment logic,

CodePudding user response:

Ok, thanks for mud of ~ ~ ~
  • Related