If I want all permutations of 1D array I have:
But if I have arr={{1,1,1}, {2,2,2}, {3,3,3}, {4,4,4}}, I don't know what should I put between brackets of next_permutation(), I tried next_permutation(arr[3], (arr+3)[3]), it does compile, but it does not permutate.Code:#include <iostream> #include <algorithm> using namespace std; main() { int arr[4]={1,2,3,4}; for (int i=0; i<=23; i++) { next_permutation(arr, arr+4); for (int j=0; j<=3; j++) { cout << arr[j] << ", "; } cout << endl;} system("PAUSE"); return 0;}
I'd like a solution to be:
1,1,1,2,2,2,3,3,3,4,4,4, (the order is not important)
1,1,1,2,2,2,4,4,4,3,3,3,
.
.
.
2,2,2,1,1,1,3,3,3,4,4,4,
etc.



LinkBack URL
About LinkBacks


