From 804709b1e0054b2345d1ccada89ab53acd428173 Mon Sep 17 00:00:00 2001 From: kara-mosr Date: Wed, 8 Oct 2025 14:18:02 +0200 Subject: [PATCH] add src_karamosr --- src_karamosr/karamosr.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src_karamosr/karamosr.c b/src_karamosr/karamosr.c index 984073b..449fc6e 100644 --- a/src_karamosr/karamosr.c +++ b/src_karamosr/karamosr.c @@ -5,7 +5,7 @@ #define LIFES 8 // Nombre de vies au debut du jeu // Fonction pour lire une lettre proposee par le joueur -char chooseLetter() { +char choose_letter() { char letter; printf("Entrez une lettre : "); scanf(" %c", &letter); // Le " " avant %c evite de lire un retour chariot @@ -14,7 +14,7 @@ char chooseLetter() { } // Fonction pour calculer la taille d'une chaine (similaire a strlen) -int wordSize(const char *fullWord) { +int word_size(const char *fullWord) { int size = 0; while (fullWord[size] != '\0') { size++; @@ -23,7 +23,7 @@ int wordSize(const char *fullWord) { } // Verifie combien de fois la lettre apparait dans fullWord -int checkLetterOccurrence(char letter, const char *fullWord) { +int letter_occurrence(char letter, const char *fullWord) { int wordsize = wordSize(fullWord); int letterOccurrence = 0; @@ -41,7 +41,7 @@ int checkLetterOccurrence(char letter, const char *fullWord) { } // Remplace les '_' par la lettre trouvee dans partialWord -void placeLetterInPartialWord(char letter, const char *fullWord, char *partialWord) { +void position_letter(char letter, const char *fullWord, char *partialWord) { int wordsize = wordSize(fullWord); for (int i = 0; i < wordsize; i++) { @@ -52,7 +52,7 @@ void placeLetterInPartialWord(char letter, const char *fullWord, char *partialWo } // Verifie si le joueur a gagne (si partialWord == fullWord) -int hasWon(const char *fullWord, const char *partialWord) { +int has_won(const char *fullWord, const char *partialWord) { return strcmp(fullWord, partialWord) == 0; // 1 si egal, 0 sinon } @@ -81,14 +81,14 @@ int main() { char letter = chooseLetter(); - int occurrence = checkLetterOccurrence(letter, fullWord); + int occurrence = letter_occurrence(letter, fullWord); if (occurrence > 0) { - placeLetterInPartialWord(letter, fullWord, partialWord); + position_letter(letter, fullWord, partialWord); } else { lifes--; } - if (hasWon(fullWord, partialWord)) { + if (has_won(fullWord, partialWord)) { won = 1; } }