Bonjour, voici mon code:
Je voudrais ajouter une condition concernant l'exécution de la boucle.Je veux rentrer dans la boucle si solution ne contient aucune lettre.
Comment puis-je coder celà?
Code :
srand( (unsigned) time (NULL) );
for ( int i = 0 ; i < Game::howManyPositions;)
{ int nextValue = rand () % (Game::howManyLetters);
char theChar = alpha[nextValue];
// lettre déjà existante?
if ( ! duplicates && i > 0 )
{ vector<char>::iterator where =
find(solution.begin(), solution.end(), theChar);
if (where != solution.end())
continue;
}
solution.push_back(theChar);
i++;
}
Après que solution soit rempli,
quand je teste if (solution[0] == ' ');
cout << "l'instruction";, instruction s'affiche alors que solution est rempli.Quelle est mon erreur?
Dautre part quand je lance pour la première fois mon prog, le vector solution est rempli à zéro ce qui est normal mais je ne vois pas comment il est initialisé:
Solution est une variable membre de human.