全比排序(自己创造的)
全比排序
思想
全比排序的思想就是拿每个数去跟它后面的数字交换,例如
这个排序跑不满
\text{code}
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define qwq ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const int N = 114514;
int n, a[N];
signed main()
{
qwq;
cin >> n;
for (int i = 1; i <= n; ++ i)//输入
cin >> a[i];
for (int i = 1; i <= n; ++ i)//从 1 比到 n
for (int j = i + 1; j <= n; ++ j)//找 a[i] 后面的比
if (a[i] > a[j])
swap(a[i], a[j]);//int temp = a[i], a[i] = a[j], a[j] = temp;
for (int i = 1; i <= n; ++ i)//输出
cout << a[i] << " ";
return 0;
}