diff --git a/APL1.1/TP08/diviseur.c b/APL1.1/TP08/diviseur.c new file mode 100644 index 0000000..1db0b2c --- /dev/null +++ b/APL1.1/TP08/diviseur.c @@ -0,0 +1,20 @@ +#include +#include + +int pgcd(int a, int b) { + if (b == 0) return a; + else if (a == 0) return b; + else { + return pgcd(b, a % b); + } +} + +int main(int argc, char * argv[]) { + + int v1, v2; + printf("Veuillez donner deux entiers : "); + scanf("%d %d", &v1, &v2); + + printf("Le plus grand diviseur commun entre %d et %d est %d\n", v1, v2, pgcd(v1, v2)); + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/APL1.1/TP08/sapin.c b/APL1.1/TP08/sapin.c new file mode 100644 index 0000000..208de25 --- /dev/null +++ b/APL1.1/TP08/sapin.c @@ -0,0 +1,19 @@ +#include +#include + +int main(int argc, char * argv[]) { + + int height; + + printf("Hauteur ? "); + scanf("%d", &height); + printf("\n"); + + for (int i = 0; i <= height; i++) { + for (int i2 = height-i; i2 > 0; i2--) printf(" "); + for (int i2 = 0; i2 < i*2-1; i2++) printf("*"); + printf("\n"); + } + return EXIT_SUCCESS; +} +