void print_combinations(const std::string &str)
{
int i, j, k;
int len = str.length();
for (i = 0; i < len - 2; i++)
{
for (j = i + 1; j < len - 1; j++)
{
for (k = j + 1; k < len; k++)
// show combination
cout << str.at(i) << str.at(j) << str.at(k) << endl;
}
}
}
This function does what I want, but I want to make it recursive, so that it can create combinations of arbitrary length.
Here is a try:
Output of ./test fjord 3: