Jme suis amusé à coder une version basique et pas très rapide mais fonctionelle qui traite que l´alphabet. Voila le code ( du C++):
- include < iostream>
- include < string>
using namespace std;
- define NOMBRE_CHAR 26
char charset[NOMBRE_CHAR] = {´a´, ´b´, ´c´, ´d´, ´e´, ´f´, ´g´, ´h´, ´i´, ´j´, ´k´, ´l´, ´m´, ´n´, ´o´, ´p´,
´q´, ´r´, ´s´, ´t´, ´u´, ´v´, ´w´, ´x´, ´y´, ´z´};
int profondeur_max;
void brutos(string prefixe, int profondeur)
{
if ( profondeur > = profondeur_max)
{
cout < < prefixe < < endl;
return;
}
for ( int char_courant = 0; char_courant < NOMBRE_CHAR; ++char_courant)
brutos(prefixe + charset[char_courant], profondeur + 1);
}
int main()
{
cin > > profondeur_max;
brutos("", 0);
return 0;
}
Il est disponible egalement ici ( plus clair mais le lien est ephemere):
http://rafb.net/paste/results/EZzZW986.html