#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <algorithm>
#include "JTools/JPermutation.hh"
#include "JMath/JMathToolkit.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
Go to the source code of this file.
|
int | main (int argc, char **argv) |
|
Example program to test permutations (JTOOLS::next_permutation).
- Author
- mdejong
Definition in file JPermutation.cc.
◆ main()
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 22 of file JPermutation.cc.
32 JParser<> zap(
"Example program to test permutations.");
40 catch(
const exception &error) {
41 FATAL(error.what() << endl);
50 if (N > buffer.size()) {
51 FATAL(
"Number of elements " << N <<
" > " << buffer.size() << endl);
54 sort(buffer.begin(), buffer.end(), less<int>());
68 DEBUG(
'[' << setw(3) <<
n <<
']');
71 DEBUG(
' ' << setw(3) << *i);
77 data.rbegin()->insert(*i);
83 DEBUG(
' ' << setw(3) << *i);
91 for (
vector<
set<int> >::const_iterator p = data.begin(); p != data.end(); ++p) {
92 for (
vector<
set<int> >::const_iterator q = p; ++q != data.end(); ) {
98 NOTICE(
"number of permutations " <<
n <<
' ' <<
factorial(buffer.size(), N) << endl);