Je provoque un problème, que je n'arrive pas à cerner.
Bonjour.
Ce code est censé générer toute les combinaisons avec les caractères de la chaine appelée chaine.
Cela fonctionne en VB, le code est dans le dernier message que j'ai posté sur cette page :
http://www.developpez.net/forums/d10...encer-travail/
Ici il y a un problème...
Raide i tou past :ccool:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
| #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
int main()
{
string mot;
int ii;
int cont ;
cont = 0;
int a;
int b;
int c;
int d;
int e;
a = 0;
b = 0;
c = 0;
d = 0;
e = 0;
int taille;
string chaine;
chaine = "abc";//lmnopqrstuvwxyzdefghijk
taille = chaine.length();
string t1[taille];
string t2[taille];
string t3[taille];
string t4[taille];
string t5[taille];
for (ii=0; ii<taille; ii++)
{
t1[ii] = chaine.substr(ii,1);
t2[ii] = chaine.substr(ii,1);
t3[ii] = chaine.substr(ii,1);
t4[ii] = chaine.substr(ii,1);
t5[ii] = chaine.substr(ii,1);
}
while (e < taille) //Fonctionne en mettant : c < taille
{ for (a =0; a < taille; a++ )
{ cout<<t5[e]<<t4[d]<<t3[c] <<t2[b]<<t1[a]<<endl;
cont++; }
b++;
if (b == taille && c == taille && d == taille)
{
b = 0;
c = 0;
d = 0;
e++;
}
if (b == taille && c == taille)
{
b = 0;
c = 0;
d++;
}
if ( b == taille)
{
b= 0;
c++; }
}
cout<< "Il y a "<<cont<<" entrées"<<endl;
system("PAUSE");
return EXIT_SUCCESS;
} |
Merci de vos lumières