This is a very enlightening problem, so I'll give you a start and let you go from there. I just wrote this up to print every combination of characters in any word and the number of total combinations, it should give you a very good idea of where to start. This is one of the simpler methods, but simple is good, right?
Code:
#include <iostream>
#include <string>
using namespace std;
void recurse ( char a[], int index )
{
char temp;
if ( a[index + 1] != '\0' ) {
temp = a[index];
a[index] = a[index + 1];
a[index + 1] = temp;
cout<< a <<endl;
recurse ( a, ++index );
}
return;
}
int main ( void )
{
unsigned i, index = 0;
char string[] = "weird";
size_t len = strlen ( string );
for ( i = 0; i < len; i++ )
recurse ( string, index );
cout<<"Total combinations: "<<(len * (len - 1))<<endl;
return EXIT_SUCCESS;
}
-Prelude