From a379ee9e1f38af1145c27c50a17acb004dad9439 Mon Sep 17 00:00:00 2001 From: Simoes Lukas Date: Mon, 14 Oct 2024 15:51:23 +0200 Subject: [PATCH] Entrainement --- .../controle_machine_B/canettes.c | 53 +++++++++++++++++++ .../controle_machine_B/chauve_souris.c | 7 +++ .../controle_machine_B/circulation.c | 23 ++++++++ .../controle_machine_B/coincidences.c | 16 ++++++ .../controle_machine_B/correspondances.c | 9 ++++ 5 files changed, 108 insertions(+) create mode 100644 DEV1.1/Entrainements/controle_machine_B/canettes.c create mode 100644 DEV1.1/Entrainements/controle_machine_B/chauve_souris.c create mode 100644 DEV1.1/Entrainements/controle_machine_B/circulation.c create mode 100644 DEV1.1/Entrainements/controle_machine_B/coincidences.c create mode 100644 DEV1.1/Entrainements/controle_machine_B/correspondances.c diff --git a/DEV1.1/Entrainements/controle_machine_B/canettes.c b/DEV1.1/Entrainements/controle_machine_B/canettes.c new file mode 100644 index 0000000..cc28833 --- /dev/null +++ b/DEV1.1/Entrainements/controle_machine_B/canettes.c @@ -0,0 +1,53 @@ +#include +#include +# define CANETTE 0.6 +# define PACK 3.39 + +int main(void) { + double budget; + double i; + int nb_packs, nb_canettes; + nb_packs = 0; + nb_canettes = 0; + printf("Quel est votre budget ? "); + scanf("%lf", &budget); + for (i = budget; i > PACK; i -= PACK) { + nb_packs++; + } + budget -= (nb_packs * PACK); + for (i = budget; i > CANETTE; i -= CANETTE) { + nb_canettes++; + } + if (nb_packs > 0 && nb_canettes > 0) { + if (nb_packs == 1) { + printf("1 pack et "); + } + else { + printf("%d packs et ", nb_packs); + } + if (nb_canettes == 1) { + printf("1 unité"); + } + else { + printf("%d unités", nb_canettes); + } + } + else if (nb_packs > 0) { + if (nb_packs == 1){ + printf("1 pack"); + } + else { + printf("%d packs", nb_packs); + } + } + else { + if (nb_canettes == 1) { + printf("1 unité"); + } + else { + printf("%d unités", nb_canettes); + } + } + printf("\n"); + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1/Entrainements/controle_machine_B/chauve_souris.c b/DEV1.1/Entrainements/controle_machine_B/chauve_souris.c new file mode 100644 index 0000000..6110a9a --- /dev/null +++ b/DEV1.1/Entrainements/controle_machine_B/chauve_souris.c @@ -0,0 +1,7 @@ +# include +# include + +int main(void){ + printf(" _ ,_, _\n / `'=) (='` \\\n/.-.-.\\/.-.-.\\\n` \" `\n"); + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1/Entrainements/controle_machine_B/circulation.c b/DEV1.1/Entrainements/controle_machine_B/circulation.c new file mode 100644 index 0000000..e38a018 --- /dev/null +++ b/DEV1.1/Entrainements/controle_machine_B/circulation.c @@ -0,0 +1,23 @@ +# include +# include + +int main(void) { + char lettre; + char fin = 'z'; + char temp; + printf("Entrez une minuscule : "); + scanf("%c", &lettre); + temp = lettre; + while (lettre != fin) { + putchar(lettre); + lettre++; + } + putchar('z'); + fin -= 25; + while (fin != temp) { + putchar(fin); + fin++; + } + putchar('\n'); + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1/Entrainements/controle_machine_B/coincidences.c b/DEV1.1/Entrainements/controle_machine_B/coincidences.c new file mode 100644 index 0000000..7e1ef4f --- /dev/null +++ b/DEV1.1/Entrainements/controle_machine_B/coincidences.c @@ -0,0 +1,16 @@ +# include +# include + +int main(void) { + int resultats[5]; + int i; + int suite_1[5] = {1, 2, 3, 4, 5}; + int suite_2[5] = {2, 3, 4, 5, 6}; + for (i = 0; i != 5; i++) { + printf("Jet n°%d : ", i+1); + scanf("%d", &resultats[i]); + getchar(); + } + /* TO DO */ + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1/Entrainements/controle_machine_B/correspondances.c b/DEV1.1/Entrainements/controle_machine_B/correspondances.c new file mode 100644 index 0000000..cad77b4 --- /dev/null +++ b/DEV1.1/Entrainements/controle_machine_B/correspondances.c @@ -0,0 +1,9 @@ +#include +#include + +int main(void) { + printf("%d\n", 31); + printf("%o\n", 031); + printf("%x\n", 0x31); + return EXIT_SUCCESS; +} \ No newline at end of file