Compare commits
5 commits
Author | SHA1 | Date | |
---|---|---|---|
6e1d65a638 | |||
2267eda745 | |||
1a3d0320f6 | |||
a9a45e0512 | |||
7f111867c4 |
3 changed files with 27 additions and 10 deletions
12
.gitlab-ci.yml
Normal file
12
.gitlab-ci.yml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
image: gcc
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- build
|
||||||
|
|
||||||
|
build:
|
||||||
|
stage: build
|
||||||
|
script:
|
||||||
|
- gcc main.c -o pendu
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- pendu
|
|
@ -1,4 +1,6 @@
|
||||||
# Pendu
|
# Pendu
|
||||||
Mon premier pendu tout language confondu, s'il y a des approximations tu peux faire une PR 😀
|
Mon premier pendu tout language confondu, s'il y a des approximations tu peux faire une PR 😀
|
||||||
|
|
||||||
Pour lancer le pendu : `git clone https://github.com/Mylloon/pendu-C.git && cd pendu-C && gcc main.c -o main && ./main listeMots.txt` devrait fonctionner.
|
Pour lancer le pendu : `git clone https://gitlab.com/Mylloon/penduEnC.git && cd penduEnC && gcc main.c -o main && ./main listeMots.txt` devrait fonctionner.
|
||||||
|
|
||||||
|
Tu peux aussi télécharger l'artéfact de la [dernière pipeline](https://gitlab.com/Mylloon/penduEnC/-/pipelines/).
|
||||||
|
|
21
main.c
21
main.c
|
@ -48,28 +48,31 @@ char * recuperationMot(const char file[]) { // pour récupérer un mot aléaotoi
|
||||||
return mot;
|
return mot;
|
||||||
}
|
}
|
||||||
|
|
||||||
int caractereSpecial(char mot) { // vérification que la lettre n'est pas un caractere special
|
int caractereSpecial(char lettre) { // vérification que la lettre n'est pas un caractere special
|
||||||
if(mot == ' ') return 1;
|
if(lettre == ' ') return 1;
|
||||||
if(mot == '\'') return 1;
|
if(lettre == '\'') return 1;
|
||||||
if(mot == '-') return 1;
|
if(lettre == '-') return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char * obfuscation(char mot[], int lettresValidees[], int taille) { // pour afficher les trous dans le mot
|
char * obfuscation(char mot[], int lettresValidees[], int taille) { // pour afficher les trous dans le mot
|
||||||
int tailleMot = taille * 2;
|
int tailleMotCache = taille * sizeof(char) * 2;
|
||||||
char * motCache = malloc(tailleMot * sizeof(char));
|
char * motCache = malloc(tailleMotCache); // x2 pour l'espace entre les "_"
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for(int i = 0; i < taille; i++) {
|
for(int i = 0; i < taille; i++) {
|
||||||
if(lettresValidees[i] != 1) {
|
if(lettresValidees[i] != 1) { // pas trouvé
|
||||||
if(caractereSpecial(mot[i]) == 0) motCache[j] = '_'; else {
|
if(caractereSpecial(mot[i]) == 0) motCache[j] = '_'; // si c'est pas un caractère spéciale
|
||||||
|
else { // si c'en est un
|
||||||
motCache[j] = mot[i];
|
motCache[j] = mot[i];
|
||||||
lettresValidees[i] = 1;
|
lettresValidees[i] = 1;
|
||||||
}
|
}
|
||||||
} else motCache[j] = mot[i];
|
} else motCache[j] = mot[i]; // trouvé
|
||||||
motCache[j + 1] = ' '; // on rajoute un espace entre les underscores
|
motCache[j + 1] = ' '; // on rajoute un espace entre les underscores
|
||||||
j = j + 2;
|
j = j + 2;
|
||||||
}
|
}
|
||||||
|
for(int i = 0; i < longueurMot(motCache); i++)
|
||||||
|
if(i >= tailleMotCache) motCache[i] = 0;
|
||||||
|
|
||||||
return motCache;
|
return motCache;
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue