一个栈实现vector降序,重点就在先给vector sort升序排序一次
双栈排序
http://www.nowcoder.com/questionTerminal/d0d0cddc1489476da6b782a6301e7dec
class TwoStacks {
public:
vector<int> twoStacksSort(vector<int> numbers) {
// write code here
sort(numbers.begin(),numbers.end());
vector<int> v;
stack<int> s;
int length = numbers.size();
for (int i = 0; i < length; i++)
{
s.push(numbers.at(i));
}
while (!s.empty())
{
v.push_back(s.top());
s.pop();
}
return v;
}
};</int></int></int></int>