这个是我自己编的排序算法,不知道是不是跟某种经典排序算法重合了,麻烦大佬看下?
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
const int N = 1e5 + 9;
int n, a[N];
vector<int> sorted;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
#ifdef BIG_BANANA_A_BIG_BANANA_YOUR_FEEL_VERY_WORDFUL
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
#endif
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i = 1; i <= n; i++) {
int index = upper_bound(sorted.begin(), sorted.end(), a[i]) - sorted.begin();
sorted.insert(sorted.begin() + index, a[i]);
}
for (auto num : sorted)
cout << num << ' ';
cout << endl;
return 0;
}