转载请标明出处http://www.cnblogs.com/haozhengfei/p/fcc2d8d8366f0cb1837cefbd077b21f1.html
双栈排序练习题
![](https://images2015.cnblogs.com/blog/1008304/201703/1008304-20170318151116182-564524714.jpg)
![](https://images2015.cnblogs.com/blog/1008304/201703/1008304-20170318151116604-2080174220.jpg)
![](https://images2015.cnblogs.com/blog/1008304/201703/1008304-20170318151117041-1092250031.jpg)
![](https://images2015.cnblogs.com/blog/1008304/201703/1008304-20170318151117432-331088487.jpg)
![](https://images2015.cnblogs.com/blog/1008304/201703/1008304-20170318151117854-1622482195.jpg)
![](https://images2015.cnblogs.com/blog/1008304/201703/1008304-20170318151118370-198086713.jpg)
![](https://images2015.cnblogs.com/blog/1008304/201703/1008304-20170318151118745-136697295.jpg)
![](https://images2015.cnblogs.com/blog/1008304/201703/1008304-20170318151119120-2009554547.jpg)
![](https://images2015.cnblogs.com/blog/1008304/201703/1008304-20170318151119385-944139511.jpg)
双栈排序练习
第6节 双栈排序练习题
请编写一个程序,按升序对栈进行排序(即最大元素位于栈顶),要求最多只能使用一个额外的栈存放临时数据,但不得将元素复制到别的数据结构中。
给定一个int[] numbers(C++中为vector<int>),其中第一个元素为栈顶,请返回排序后的栈。请注意这是一个栈,意味着排序过程中你只能访问到第一个元素。
测试样例:
[1,2,3,4,5]
返回:[5,4,3,2,1]
您的代码已保存
答案正确:恭喜!您提交的程序通过了所有的测试用例
答案正确:恭喜!您提交的程序通过了所有的测试用例