mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-04-04 02:59:43 +08:00
fix: fix deprecation warning for macOS (#2711)
Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com>
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <random>
|
||||
|
||||
|
||||
/**
|
||||
@@ -50,8 +51,10 @@ std::array <T, N> shuffle (std::array <T, N> arr) {
|
||||
template <typename T, size_t N>
|
||||
std::array <T, N> randomized_bogosort (std::array <T, N> arr) {
|
||||
// Untill array is not sorted
|
||||
std::random_device random_device;
|
||||
std::mt19937 generator(random_device());
|
||||
while (!std::is_sorted(arr.begin(), arr.end())) {
|
||||
std::random_shuffle(arr.begin(), arr.end());// Shuffle the array
|
||||
std::shuffle(arr.begin(), arr.end(), generator);// Shuffle the array
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user