TP08 Boucles (encore)
This commit is contained in:
parent
8a59a181a1
commit
abbd939ddc
20
APL1.1/TP08/diviseur.c
Normal file
20
APL1.1/TP08/diviseur.c
Normal file
@ -0,0 +1,20 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
|
||||
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;
|
||||
}
|
19
APL1.1/TP08/sapin.c
Normal file
19
APL1.1/TP08/sapin.c
Normal file
@ -0,0 +1,19 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user