Little Tricks

「对于德国的奴隶,没有什么比死亡更可怕,感谢这场核战!」
— The New Order:Last Days of Europe · «最后的自由»,TNO启示录事件
首页 » 学习 » Little Tricks

对拍

打乱数组

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n = 8;
    vector<int> a(n);
    iota(a.begin(), a.end(), 1); // a = {1,2,3...n}
    
    mt19937 rnd(time(0));
    shuffle(a.begin(), a.end(), rnd); // 打乱排列
    
    for(int x : a) cout << x << " ";
    return 0;
}

Leave a Comment

您的邮箱地址不会被公开。 必填项已用 * 标注