一开始是想做新型排序算法,结果不输出,难受死了
#include<bits/stdc++.h>
using namespace std;
int sn[100],n;
stack<int> a;stack<int> b;stack<int> c;
int main(){
cin >> n;
for(int i=1;i<=n;i++)cin >> sn[i];
for(int i=1;i<=n;i++)a.push(sn[i]);
while(true){
for(int i=1;i<=n;i++){
if(!a.empty() && a.top() > b.top()){
b.push(a.top());
}else if(a.empty()){
b.push(a.top());
}else{
c.push(a.top());
}
a.pop();
}
if(c.empty())break;
}
for(int i=1;i<=n;i++){
sn[i]=b.top();
b.pop();
}
for(int i=1;i<=n;i++)cout << sn[i] << " ";
return 0;
}