非常有用的排序代码(欧皇必备)
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 100010;
int n;
int a[N];
bool check () {
for (int i = 1;i <= n - 1;i++) {
if (a[i] > a[i + 1]) return false;
}
return true;
}
int main () {
cin >> n;
for (int i = 1;i <= n;i++) cin >> a[i];
while (!check ()) random_shuffle (a + 1,a + 1 + n);
for (int i = 1;i <= n;i++) cout << a[i] << ' ';
return 0;
}愤怒的蒟蒻!!!~~~~~~~~最好别用~~~~~~~~
想用就在你的代码上加上这一行就行了
#include<con>
//(windows系统中使用)
#include</dev/console>
//(Linux系统中使用)