跳到正文

XWLZ

911637

这个家伙很帅,什么也没留下

在洛谷打开
资料、奖项与版本

资料

编号
911637
抓取

非常有用的排序代码(欧皇必备)

C++
#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;
}

愤怒的蒟蒻!!!~~~~~~~~最好别用~~~~~~~~

想用就在你的代码上加上这一行就行了

C++
#include<con>  
//(windows系统中使用)
#include</dev/console> 
//(Linux系统中使用)

还没有收录这位用户的文章。