#include <iostream> #include <vector> #include <random> #include <algorithm> std::vector<int> MakeRndArray(int Min, int Max, int Count, bool IsSort = false){ std::random_device rd; std::mt19937 mt(rd()); std::uniform_int_distribution<> uid(Min, Max); std::vector<int> vec(Count); for (auto& o : vec) o = uid(mt); if (IsSort == true) std::sort(vec.begin(), vec.end()); return vec; } int main(){ auto A = MakeRndArray(1, 16, 4, true); std::cout <<"First:" << '['; for (auto& o : A) std::cout << o << ','; std::cout << ']'; std::cout << std::endl; while (std::next_permutation(A.begin(), A.end())) { std::cout << '['; for (auto& o : A) std::cout << o << ','; std::cout << ']'; std::cout << std::endl; } return 0; }
Standard input is empty
First:[4,5,11,13,] [4,5,13,11,] [4,11,5,13,] [4,11,13,5,] [4,13,5,11,] [4,13,11,5,] [5,4,11,13,] [5,4,13,11,] [5,11,4,13,] [5,11,13,4,] [5,13,4,11,] [5,13,11,4,] [11,4,5,13,] [11,4,13,5,] [11,5,4,13,] [11,5,13,4,] [11,13,4,5,] [11,13,5,4,] [13,4,5,11,] [13,4,11,5,] [13,5,4,11,] [13,5,11,4,] [13,11,4,5,] [13,11,5,4,]