From 232ac45261c9194acc6c3355db1a81a831546ed7 Mon Sep 17 00:00:00 2001 From: HORVILLE Ewen Date: Tue, 19 Oct 2021 14:51:16 +0200 Subject: [PATCH] =?UTF-8?q?Contr=C3=B4le=20Machine?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- APL1.1/controle_machine/rangement.c | 21 +++++++++++++ APL1.1/controle_machine/regle.c | 19 ++++++++++++ APL1.1/controle_machine/regression.c | 43 +++++++++++++++++++++++++++ APL1.1/controle_machine/reticule.c | 44 ++++++++++++++++++++++++++++ APL1.1/controle_machine/rongeur.c | 15 ++++++++++ 5 files changed, 142 insertions(+) create mode 100644 APL1.1/controle_machine/rangement.c create mode 100644 APL1.1/controle_machine/regle.c create mode 100644 APL1.1/controle_machine/regression.c create mode 100644 APL1.1/controle_machine/reticule.c create mode 100644 APL1.1/controle_machine/rongeur.c diff --git a/APL1.1/controle_machine/rangement.c b/APL1.1/controle_machine/rangement.c new file mode 100644 index 0000000..44cb48c --- /dev/null +++ b/APL1.1/controle_machine/rangement.c @@ -0,0 +1,21 @@ +#include +#include + +int main(int argc, char * argv[]) { + unsigned long x = 6UL; + + int y = 0x6; + + double z = 6.0; /*On pourrait croire à tord d'utiliser un + float mais il faut 'f' après le 6 pour en faire un float.*/ + + char w = '\66'; /* Les guillemets simples indiquent un caractère + les guillemets doubles indiquent une chaine de caractères.*/ + + printf("%ld\n", x); + printf("%d\n", y); + printf("%f\n", z); //printf utilise '%f' pour les floats et les doubles + printf("%c\n", w); + return EXIT_SUCCESS; +} + diff --git a/APL1.1/controle_machine/regle.c b/APL1.1/controle_machine/regle.c new file mode 100644 index 0000000..659155e --- /dev/null +++ b/APL1.1/controle_machine/regle.c @@ -0,0 +1,19 @@ +#include +#include + +int main(int argc, char * argv[]) { + int taille; + + printf("Entrez la longueur désirée (entre 1 et 9) : "); + scanf("%d", &taille); + + printf("|"); + for (int i = 0; i < taille; i++) printf("''''|''''|"); + + printf("\n0"); + for (int i = 0; i < taille; i++) printf(" %d", i+1); + + printf("\n"); + return EXIT_SUCCESS; +} + diff --git a/APL1.1/controle_machine/regression.c b/APL1.1/controle_machine/regression.c new file mode 100644 index 0000000..a8510d8 --- /dev/null +++ b/APL1.1/controle_machine/regression.c @@ -0,0 +1,43 @@ +#include +#include +#include + +#define POUCE 2.56 +#define PIED 30.72 + +int main(int argc, char * argv[]) { + int pieds = 0, pouces = 0; + double taille; + + printf("Veuillez indiquer votre taille : "); + scanf("%lf", &taille); + + taille *= 100; + taille = (double)lround(taille); + + while (taille >= PIED) { + taille -= PIED; + pieds++; + } + + while (taille >= POUCE) { + taille -= POUCE; + pouces++; + } + + + if (pieds > 0) { + if (pouces > 0) { + printf("Vous faites %d pied%s et %d pouce%s\n", pieds, pieds > 1 ? "s" : "", + pouces, pouces > 1 ? "s" : ""); + } else { + printf("Vous faites %d pied%s\n", pieds, pieds > 1 ? "s" : ""); + } + + } else if (pouces > 0) { + printf("Vous faites %d pouce%s\n", pouces, pouces > 1 ? "s" : ""); + } else printf("Vous faites moins d'un pouce !\n"); + + return EXIT_SUCCESS; +} + diff --git a/APL1.1/controle_machine/reticule.c b/APL1.1/controle_machine/reticule.c new file mode 100644 index 0000000..a90f2fb --- /dev/null +++ b/APL1.1/controle_machine/reticule.c @@ -0,0 +1,44 @@ +#include +#include + +int main(int argc, char * argv[]) { + + int nb_square; + + printf("Veuillez indiquer le nombre de carrés : "); + scanf("%d", &nb_square); + + + for (int i = 0; i < nb_square; i++) { + for (int i2 = 0; i2 < i; i2++) printf("| "); + + printf("+"); + for (int i2 = 0; i2 < ((nb_square-i)*2)-1; i2++) { + printf("--"); + } + printf("+"); + + + for (int i2 = 0; i2 < i; i2++) printf(" |"); + printf("\n"); + } + + for (int i = 0; i < nb_square; i++) printf("| "); + for (int i = 0; i < nb_square; i++) printf(" |"); + printf("\n"); + + for (int i = nb_square-1; i >= 0; i--) { + for (int i2 = 0; i2 < i; i2++) printf("| "); + + printf("+"); + for (int i2 = 0; i2 < ((nb_square-i)*2)-1; i2++) { + printf("--"); + } + printf("+"); + + + for (int i2 = 0; i2 < i; i2++) printf(" |"); + printf("\n"); + } + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/APL1.1/controle_machine/rongeur.c b/APL1.1/controle_machine/rongeur.c new file mode 100644 index 0000000..39ec4d8 --- /dev/null +++ b/APL1.1/controle_machine/rongeur.c @@ -0,0 +1,15 @@ +#include +#include + +int main(int argc, char * argv[]) { + puts(" (\\_/)"); + puts(" .-""-.-.-' a\\"); + puts(" / \\ _.--'"); + puts("(\\ /_---\\\\_\\_"); + puts(" `'-."); + puts(" ,__)"); + + //Ne pas oublier de doubler tous les \ autrement il va y avoir des problèmes de formattage. + return EXIT_SUCCESS; +} +