# include # include void perm_next ( int n, int p[], int &rank ); using namespace std; int main ( ) // // PERM_TEST demonstrates the use of PERM_NEXT to generate permutations. // { int i, n = 4, p[4], rank; rank = -1; while ( true ) { perm_next ( n, p, rank ); if ( rank == -1 ) { break; } cout << " " << rank << ": "; for ( i = 0; i < n; i++ ) { cout << " " << p[i]; } cout << "\n"; } return 0; }