#include <algorithm>
#include <vector>
#include <functional>
using namespace std;
int main ()
{
vector <int> v;
v.push_back (2);
v.push_back (1);
v.push_back (3);
v.push_back (1);
sort ( v.begin (), v.end (), greater <int> () );
// descending sort, header : functional
do {
printf ("%d %d %d %d \n", v [0], v [1], v [2], v [3]);
} while ( prev_permutation ( v.begin (), v.end () ) );
return 0;
}
/* output
3 2 1 1
3 1 2 1
3 1 1 2
2 3 1 1
2 1 3 1
2 1 1 3
1 3 2 1
1 3 1 2
1 2 3 1
1 2 1 3
1 1 3 2
1 1 2 3
Process returned 0 (0x0)
execution time : 0.031 s
Press any key to continue.
*/
Published by Shahab
Completed B.Sc in CSE, @United International University, Dhaka.
Currently working as Development Engineer, Android and iOS Application.
View all posts by Shahab