From bda03135c6e4f13bda6b94e03df47030cf1adf9f Mon Sep 17 00:00:00 2001 From: Simoes Lukas Date: Tue, 24 Sep 2024 15:03:19 +0200 Subject: [PATCH] Fin TP10 --- DEV1.1/TP09/#TP09_reponses.txt# | 33 ++++++++++++++++++ DEV1.1/TP09/TP09_reponses.txt | 37 ++++++++++++++++++++ DEV1.1/TP09/tests.c | 39 +++++++++++++++++++++ DEV1.1/TP10/TP10_reponses.txt | 62 +++++++++++++++++++++++++++++++++ DEV1.1/TP10/tests.c | 26 ++++++++++++++ 5 files changed, 197 insertions(+) create mode 100644 DEV1.1/TP09/#TP09_reponses.txt# create mode 100644 DEV1.1/TP09/TP09_reponses.txt create mode 100644 DEV1.1/TP09/tests.c create mode 100644 DEV1.1/TP10/TP10_reponses.txt create mode 100644 DEV1.1/TP10/tests.c diff --git a/DEV1.1/TP09/#TP09_reponses.txt# b/DEV1.1/TP09/#TP09_reponses.txt# new file mode 100644 index 0000000..288a298 --- /dev/null +++ b/DEV1.1/TP09/#TP09_reponses.txt# @@ -0,0 +1,33 @@ +------- TP09 : Boucles (encore) ------- + +1. + +# include +# include + +int main(void) { + int hauteur; + int temp_espaces; + int temp_etoiles; + int i; + int j; + temp_etoiles = 1; + printf("Hauteur ? "); + scanf("%d", &hauteur); + printf("\n"); + temp_espaces = hauteur - 1; + for (; hauteur != 0; hauteur -= 1) { + for (i = 0; i != temp_espaces; i += 1) { + printf(" "); + } + temp_espaces -= 1; + for (j = 0; j != temp_etoiles; j += 1) { + printf("*"); + } + temp_etoiles += 2; + printf("\n"); + } + return EXIT_SUCCESS; +} + +2. diff --git a/DEV1.1/TP09/TP09_reponses.txt b/DEV1.1/TP09/TP09_reponses.txt new file mode 100644 index 0000000..2098f48 --- /dev/null +++ b/DEV1.1/TP09/TP09_reponses.txt @@ -0,0 +1,37 @@ +------- TP09 : Boucles (encore) ------- + +1. + +# include +# include + +int main(void) { + int hauteur; + int temp_espaces; + int temp_etoiles; + int i; + int j; + temp_etoiles = 1; + printf("Hauteur ? "); + scanf("%d", &hauteur); + printf("\n"); + temp_espaces = hauteur - 1; + for (; hauteur != 0; hauteur -= 1) { + for (i = 0; i != temp_espaces; i += 1) { + printf(" "); + } + temp_espaces -= 1; + for (j = 0; j != temp_etoiles; j += 1) { + printf("*"); + } + temp_etoiles += 2; + printf("\n"); + } + return EXIT_SUCCESS; +} + + +-------------------------------------------- + +2. + diff --git a/DEV1.1/TP09/tests.c b/DEV1.1/TP09/tests.c new file mode 100644 index 0000000..aaa0ea5 --- /dev/null +++ b/DEV1.1/TP09/tests.c @@ -0,0 +1,39 @@ +# include +# include + +int main(void) { + int hauteur; + char choix; + int i; + int j; + printf("_______________\n t) Triangle\n c) Carré\n q) Quitter\n Votre choix ? "); + choix = getchar(); + while (choix != 'q') { + printf("\n\nHauteur ? "); + scanf("%d", &hauteur); + if (choix == 't') { + for (i = 0; i != hauteur; i++) { + for (j = 0; j != i; j++) { + printf("*"); + } + printf("\n"); + } + } + else { + for (i = 0; i != hauteur; i++) { + printf("*"); + } + printf("\n"); + for (i = 0; i != (hauteur - 2); i++) { + printf("*"); + for (j = 0; j != (hauteur - 2); j++) { + printf(" "); + } + printf("*\n"); + } + } + printf("_______________\n t) Triangle\n c) Carré\n q) Quitter\n Votre choix ? "); + choix = getchar(); + } + return EXIT_SUCCESS; +} diff --git a/DEV1.1/TP10/TP10_reponses.txt b/DEV1.1/TP10/TP10_reponses.txt new file mode 100644 index 0000000..dcb1b33 --- /dev/null +++ b/DEV1.1/TP10/TP10_reponses.txt @@ -0,0 +1,62 @@ +-------- TP10 : Types -------- + +# include +# include + +int main(void) { + printf("%d\n", 77); + printf("%c%c\n", '7', '7'); + printf("%hd\n", 77); + printf("%u\n", 77U); + printf("%ld\n", 77L); + printf("%lu\n", 77UL); + return EXIT_SUCCESS; +} + +------------------------------- + +# include +# include + +int main(void) { + int valeur; + char texte; + printf("Entier : "); + scanf("%d", &valeur); + texte = (char) valeur; + printf("%c", texte); + return EXIT_SUCCESS; +} + + +Lorsque l'on passe d'un int à un char, le char prend comme valeur +le numéro du caractère ASCII correspondant à l'int converti. + +----------------------------- + +# include +# include + +int main(void) { + int lundi; + int mardi; + int mercredi; + int jeudi; + int vendredi; + printf("1er jour : "); + scanf("%d", &lundi); + getchar(); + printf("\n2e jour : "); + scanf("%d", &mardi); + getchar(); + printf("\n3e jour : "); + scanf("%d", &mercredi); + getchar(); + printf("\n4e jour : "); + scanf("%d", &jeudi); + getchar(); + printf("\n5e jour : "); + scanf("%d", &vendredi); + printf("\nMoyenne : %.2f", (double) (lundi + mardi + mercredi + jeudi + vendredi) / 5); + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1/TP10/tests.c b/DEV1.1/TP10/tests.c new file mode 100644 index 0000000..cac8ed3 --- /dev/null +++ b/DEV1.1/TP10/tests.c @@ -0,0 +1,26 @@ +# include +# include + +int main(void) { + int lundi; + int mardi; + int mercredi; + int jeudi; + int vendredi; + printf("1er jour : "); + scanf("%d", &lundi); + getchar(); + printf("\n2e jour : "); + scanf("%d", &mardi); + getchar(); + printf("\n3e jour : "); + scanf("%d", &mercredi); + getchar(); + printf("\n4e jour : "); + scanf("%d", &jeudi); + getchar(); + printf("\n5e jour : "); + scanf("%d", &vendredi); + printf("\nMoyenne : %.2f", (double) (lundi + mardi + mercredi + jeudi + vendredi) / 5); + return EXIT_SUCCESS; +} \ No newline at end of file