algorithm: random_shuffle

博客介绍了random_shuffle的作用,它可打乱已排好序的容器,如vector,并提及后续会展示其用法。

random_shuffle的作用是打乱已经排好序的容器,例如vector。其用法如下所示。

vector<int> nums(10);
random_shuffle(nums.begin(), nums.end());

 

51 0 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\random In file included from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/random 66 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\stl_algo.h from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/bits/stl_algo.h 62 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\algorithm from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/algorithm 8 C:\Users\admin\Documents\未命名4.cpp from C:\Users\admin\Documents\未命名4.cpp C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\random.tcc In instantiation of 'typename std::enable_if<std::is_class<_Sseq>::value>::type std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::seed(_Sseq&) [with _Sseq = std::random_device; _UIntType = unsigned int; long long unsigned int __w = 32ull; long long unsigned int __n = 624ull; long long unsigned int __m = 397ull; long long unsigned int __r = 31ull; _UIntType __a = 2567483615u; long long unsigned int __u = 11ull; _UIntType __d = 4294967295u; long long unsigned int __s = 7ull; _UIntType __b = 2636928640u; long long unsigned int __t = 15ull; _UIntType __c = 4022730752u; long long unsigned int __l = 18ull; _UIntType __f = 1812433253u; typename std::enable_if<std::is_class<_Sseq>::value>::type = void]': 516 19 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\random.h required from 'std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::mersenne_twister_engine(_Sseq&) [with _Sseq = std::random_device; <template-parameter-2-2> = void; _UIntType = unsigned int; long long unsigned int __w = 32ull; long long unsigned int __n = 624ull; long long unsigned int __m = 397ull; long long unsigned int __r = 31ull; _UIntType __a = 2567483615u; long long unsigned int __u = 11ull; _UIntType __d = 4294967295u; long long unsigned int __s = 7ull; _UIntType __b = 2636928640u; long long unsigned int __t = 15ull; _UIntType __c = 4022730752u; long long unsigned int __l = 18ull; _UIntType __f = 1812433253u]' 90 40 C:\Users\admin\Documents\未命名4.cpp required from here 360 2 C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\bits\random.tcc [Error] 'class std::random_device' has no member named 'generate'
11-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值