#include<bits/stdc++.h>
using namespace std;
stack<int> sorting(stack<int> &mystack)
{
stack<int> m;
while (!mystack.empty)
{
if (m.empty || (m.top <= mystack.top))
{
m.push(mystack.top);
mystack.pop;
}
else {
int t = mystack.top;
mystack.pop;
while (m.top > t)
{
mystack.push(m.top);
m.pop;
}
m.push(t);
}
}
return m;
}
int main()
{
stack<int> myStack;
int n;
cin >> n;
for (int i = 1; i <= n; i++)
{
int t;
cin >> t;
myStack.push(t);
}
stack<int> result = sorting(myStack);
while (!result.empty)
{
myStack.push(result.top);
result.pop;
}
while (!myStack.empty)
{
cout << myStack.top;
myStack.pop;
cout << endl;
}
return 0;
}
以上是我写的栈排序的代码,想知道哪里错了,怎么改。VS给的报错提示实
在不怎么懂,拜托各位大佬指正