If you want to sort the stack from the top to the bottom, you are allowed to apply for only one stack. In addition, you can apply for new variables, but not additional data structures. How do I do that sort? 【 答 案 】 The stack to be sorted is called stack and the secondary stack to be requested is called help. Perform the pop operation on the stack, and the popup element is denoted as cur. If a cur is equal to or less than he | p element of the stack, is to press the cur directly into a help. If cur is greater than the help of stack elements, it will help the elements one by one pops up, press one by one into the stack, until the cur less than or equal to hep element of the stack, then he pushed cur | p. Keep doing this until all the elements in the stack are pressed into help. Will he finally press | p all of the elements in one by one into the stack, the sorting is completed.
Welcome to communicate with the code that something: https://mp.csdn.net/postedit/80325970?utm_source=zwqt