diff --git a/DEV1.1/TP08/TP08_reponses.txt b/DEV1.1/TP08/TP08_reponses.txt new file mode 100644 index 0000000..1dc735d --- /dev/null +++ b/DEV1.1/TP08/TP08_reponses.txt @@ -0,0 +1,41 @@ +------- TP08 : Boucles (suite) ------- + +1. + +# include +# include + +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. + diff --git a/DEV1.1/TP08/tests.c b/DEV1.1/TP08/tests.c new file mode 100644 index 0000000..9155bc5 --- /dev/null +++ b/DEV1.1/TP08/tests.c @@ -0,0 +1,31 @@ +# include +# include + +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; +} \ No newline at end of file