This commit is contained in:
Simoes Lukas 2024-09-17 17:31:02 +02:00
parent f23461e2cb
commit ab52c40223
2 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,41 @@
------- TP08 : Boucles (suite) -------
1.
# include <stdio.h>
# include <stdlib.h>
int main(void) {
int aleatoire;
int i;
int entree;
int VALEUR_MAX;
int NB_TENTATIVES;
VALEUR_MAX = 100;
NB_TENTATIVES = 5;
srand(time(NULL));
aleatoire = (rand() % VALEUR_MAX);
for (i = 1; i <= NB_TENTATIVES; i++) {
printf("Entrez un nombre : ");
scanf("%d", &entree);
if (entree < aleatoire) {
printf("+\n");
}
else if (entree > aleatoire) {
printf("-\n");
}
else {
printf("Bonne réponse");
}
}
if (aleatoire != entree) {
printf("Perdu");
}
return EXIT_SUCCESS;
}
-----------------------
2.

31
DEV1.1/TP08/tests.c Normal file
View File

@ -0,0 +1,31 @@
# include <stdio.h>
# include <stdlib.h>
int main(void) {
int aleatoire;
int i;
int entree;
int VALEUR_MAX;
int NB_TENTATIVES;
VALEUR_MAX = 100;
NB_TENTATIVES = 5;
srand(time(NULL));
aleatoire = (rand() % VALEUR_MAX);
for (i = 1; i <= NB_TENTATIVES; i++) {
printf("Entrez un nombre : ");
scanf("%d", &entree);
if (entree < aleatoire) {
printf("+\n");
}
else if (entree > aleatoire) {
printf("-\n");
}
else {
printf("Bonne réponse");
}
}
if (aleatoire != entree) {
printf("Perdu");
}
return EXIT_SUCCESS;
}