23{
25
27 unsigned int N;
29
30 try {
31
32 JParser<> zap(
"Example program to test permutations.");
33
37
38 zap(argc, argv);
39 }
40 catch(const exception &error) {
41 FATAL(error.what() << endl);
42 }
43
44
46
47
48 if (N > buffer.size()) {
49 FATAL(
"Number of elements " << N <<
" > " << buffer.size() << endl);
50 }
51
52 sort(buffer.begin(), buffer.end(), less<int>());
53
55
57
59
61
62 do {
63
65
66 DEBUG(
'[' << setw(3) << n <<
']');
67
68 for (vector<int>::const_iterator i = buffer.begin(); i != p; ++i) {
69 DEBUG(
' ' << setw(3) << *i);
70 }
71
73
74 for (vector<int>::const_iterator i = buffer.begin(); i != p; ++i) {
75 data.rbegin()->insert(*i);
76 }
77
79
80 for (vector<int>::const_iterator i = p; i != buffer.end(); ++i) {
81 DEBUG(
' ' << setw(3) << *i);
82 }
83
85
87
88
92 }
93 }
94
95
96 NOTICE(
"number of permutations " << n <<
' ' <<
factorial(buffer.size(), N) << endl);
97
99}
#define DEBUG(A)
Message macros.
#define ASSERT(A,...)
Assert macro.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Utility class to parse command line options.
long long int factorial(const long long int n)
Determine factorial.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
counter_type advance(counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
Advance counter.