Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!leah!rpi!crdgw1!ge-dab!peora!ucf-cs!ucf-cs.ucf.edu!vanb From: vanb@ucf-cs.ucf.edu Newsgroups: comp.lang.c Subject: Re: A permutations producing algorithm Message-ID: <2400006@ucf-cs.ucf.edu> Date: 24 Jul 89 21:47:00 GMT References: <1392@umiami.miami.edu> Lines: 98 Nf-ID: #R:umiami.miami.edu:-139200:ucf-cs.ucf.edu:2400006:000:2836 Nf-From: ucf-cs.ucf.edu!vanb Jul 24 17:47:00 1989 The following is the simplest way (coding-wise) I know of to code the 'all combinations' problem: #define NVARS ?? /* The number of variables */ #define MAXVALS ?? /* The maksimum number of values for any variable */ /* (Please forgive the spelling - I'm having */ /* trouble with my 'eks' key. */ int values[NVARS][MAVALS]; /* values[i][j] is the jth value of variable i */ int nvals[NVARS]; /* nvals[i] is the number of values of variable i */ int vector[NVARS]; /* this is a vector of chosen values we're */ /* going to build. vector[i] is the value chosen */ /* from variable i. */ void main( void ) { /* Read in or calculate 'values' and 'nvals' */ choosem( 0 ); } void choosem( int level ) { int i, j; if( level == NVARS ) { /* Do whatever you need to do with the vector */ } else { for( i=0; i