Skip to content

Commit 87f2fbb

Browse files
authored
Add files via upload
0 parents  commit 87f2fbb

24 files changed

+3275
-0
lines changed

TP1/TP1.c

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#include "TP1.h"
2+
void pendu_();
3+
4+
int main()
5+
{
6+
pendu_();
7+
return 0;
8+
}
9+
10+
void pendu_()
11+
{
12+
char mot[30];
13+
printf("Entrez un mot : ");
14+
fgets(mot, sizeof mot, stdin);
15+
char len_mot = strlen(mot);
16+
system("clear");
17+
char new_mot[30];
18+
int nbr_tentative = 0;
19+
20+
for (size_t i = 0; i <=len_mot && mot[i]!='\n'; ++i) {
21+
switch (*(mot+i)) {
22+
case ' ':
23+
case '-':
24+
*(new_mot+i) = *(mot+i);
25+
break;
26+
default:
27+
*(new_mot+i) ='*';
28+
}
29+
}
30+
printf("%d %d\n", strlen(mot), strlen(new_mot));
31+
printf("%c\n",*(new_mot+len_mot-1));
32+
*(new_mot+len_mot) = '\n';
33+
*(new_mot+len_mot+1) = '\0';
34+
printf("%d %d\n", strlen(mot), strlen(new_mot));
35+
printf("\n%s\n",new_mot);
36+
/* char c;
37+
38+
while ((strcmp(mot,new_mot)!=0) && (nbr_tentative<10))
39+
{
40+
printf("\nIl vous reste %d tentatives !",10-nbr_tentative);
41+
printf("\nun caractère : ");
42+
c = getchar();
43+
while (getchar() != '\n') ;
44+
for (size_t i = 0; i < len_mot; ++i)
45+
{
46+
if (c == *(mot+i))
47+
{
48+
*(new_mot+i) = c;
49+
}
50+
}
51+
printf("%s\n",new_mot);
52+
nbr_tentative ++;
53+
}
54+
if (nbr_tentative==10)
55+
printf("\nVous avez utilisé toutes les tentatives possibles (%d), c'est PERDU !\n",nbr_tentative);
56+
else
57+
printf("\nVous avez GAGNE en %d tentatives !\n",nbr_tentative);*/
58+
}

0 commit comments

Comments
 (0)