22int main(
int argc,
char **argv)
32 JParser<> zap(
"Example program to test permutations.");
40 catch(
const exception &error) {
41 FATAL(error.what() << endl);
48 if (N > buffer.size()) {
49 FATAL(
"Number of elements " << N <<
" > " << buffer.size() << endl);
52 sort(buffer.begin(), buffer.end(), less<int>());
66 DEBUG(
'[' << setw(3) << n <<
']');
68 for (vector<int>::const_iterator i = buffer.begin(); i != p; ++i) {
69 DEBUG(
' ' << setw(3) << *i);
74 for (vector<int>::const_iterator i = buffer.begin(); i != p; ++i) {
75 data.rbegin()->insert(*i);
80 for (vector<int>::const_iterator i = p; i != buffer.end(); ++i) {
81 DEBUG(
' ' << setw(3) << *i);
86 }
while (next_permutation(buffer.begin(), p, buffer.end(), less<int>()));
89 for (
vector<
set<int> >::const_iterator p = data.begin(); p != data.end(); ++p) {
90 for (
vector<
set<int> >::const_iterator q = p; ++q != data.end(); ) {
96 NOTICE(
"number of permutations " << n <<
' ' << factorial(buffer.size(), N) << endl);
98 ASSERT(n == factorial(buffer.size(), N));