📜  Fisher-Yates shuffle 算法 c++ 代码示例

📅  最后修改于: 2022-03-11 14:44:57.349000             🧑  作者: Mango

代码示例1
default_random_engine seed;
vector shuffle(vectorarr) {
        
        for(int i =arr.size()-1 ;i>0;i--)
        {       
                int indx =  uniform_int_distribution(0, i)(seed);
                swap(arr[i],arr[indx]);
                
        }
        return arr;
    }