I\'m attempting to write a program that will generate a text file with every possible permutation of the alphabet from one character up to twenty-nine characters. I\'ve chosen 2
This is what I would do:
#include
void printWords(std::string& word, int index, int last)
{
std::cout << word << "\n";
if (index != last)
{
for(char loop = 'a'; loop <= 'z'; ++loop)
{
word[index] = loop;
printWords(word, index+1, last);
}
word[index] = ' ';
}
}
int main()
{
std::string word(" "); // 29 space
printWords(word,0,word.length());
}