fonctionnalité diff

This commit is contained in:
Florian GENIQUE 2024-10-15 11:25:09 +02:00
parent 2361771f21
commit 9bc84202a2
2 changed files with 47 additions and 1 deletions

BIN
a.out Executable file

Binary file not shown.

48
pendu.c
View File

@ -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;