This function will eventually calculate all the permutaions for a set of letter of n length. I'm stumped on whether to declare something as a string or a char or a char and a char *. Any help would be appreciated.
Code:#include <iostream> #include <string> using namespace std; char GETALLCOMBOZ(char charact,int num){ char *myArr = new char[num+1]; int numofperms; char comboz; bool booler = false; do { myArr[numofperms] = myArr[numofperms]+ 1; if (numofperms == num) { comboz = comboz.substr(0, num - 1)+ charact.substr(myArr[numofperms], 1); } else { comboz = comboz + charact.substr(myArr[numofperms], 1); } if(myArr[numofperms] != strlen(charact) + 1) { if(numofperms!= num) { numofperms = numofperms + 1; } else { cout << comboz; } else { if (numofperms == 1) { booler = true; } else { myArr[numofperms] = 0; numofperms = numofperms - 1; comboz = comboz.substr(0, numofperms - 1); } } }while (booler != true); }



LinkBack URL
About LinkBacks



CornedBee