fonctionnalité diff
This commit is contained in:
parent
2361771f21
commit
9bc84202a2
48
pendu.c
48
pendu.c
@ -35,9 +35,55 @@ void display_hangman(int tries) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char* choix_diff(){
|
||||
int compteur_mot = 0;
|
||||
int taille = 0;
|
||||
int i =0;
|
||||
printf("Choisissez la difficulté du jeu en choisissant la taille : ");
|
||||
scanf(" %d", &taille);
|
||||
|
||||
static char word_finale[100] = "";
|
||||
const char *choisis[MAX_WORDS];
|
||||
|
||||
|
||||
|
||||
word_finale[0] = '\0';
|
||||
|
||||
while (taille >= 3) {
|
||||
const char *word;
|
||||
int word_length;
|
||||
|
||||
do {
|
||||
word = words[rand() % MAX_WORDS];
|
||||
word_length = strlen(word);
|
||||
for(i;i<compteur_mot;i++){
|
||||
if(word == choisis[i]){
|
||||
word_length = taille + 1;
|
||||
}
|
||||
}
|
||||
|
||||
} while (word_length > taille);
|
||||
|
||||
choisis[compteur_mot] = word;
|
||||
compteur_mot++;
|
||||
|
||||
strcat(word_finale, word);
|
||||
|
||||
|
||||
taille -= word_length;
|
||||
if(taille > 3){
|
||||
strcat(word_finale, "-");
|
||||
}
|
||||
}
|
||||
|
||||
return word_finale;
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
srand(time(NULL));
|
||||
const char *word = words[rand() % MAX_WORDS];
|
||||
char *word = choix_diff();
|
||||
int word_length = strlen(word);
|
||||
char guessed[word_length];
|
||||
int tries = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user