Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
shuffle_example
#include <iostream> #include <algorithm> #include <vector> #include <random> #include <chrono> int main() { std::vector<int> shuffleme {0,1,2,3,4,5,6,7,8,9}; // get a time based seed unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); // shuffle the vector with the seed obtained std::shuffle(shuffleme.begin(), shuffleme.end(), std::default_random_engine(seed)); std::cout << "Shuffled elements are : "; // iterate through the vector and print the elements for(auto element : shuffleme) { std::cout << element << " "; } return 0; }
run
|
edit
|
history
|
help
0
Dar
Day3
Hi
cppPyFoodVatTip
test if nullptr
frequsency
Einstein's Physics
ArrAdSubMul
GCC compiler bug (should output 0 1)
replace_copy-30-Seconds-of-C++