DEV/DEV1.1/TP09/TP09_reponses.txt

38 lines
616 B
Plaintext
Raw Normal View History

2024-09-24 15:03:19 +02:00
------- TP09 : Boucles (encore) -------
1.
# include <stdio.h>
# include <stdlib.h>
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.