This commit is contained in:
Simoes Lukas
2024-09-24 15:03:19 +02:00
parent ab52c40223
commit bda03135c6
5 changed files with 197 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
------- 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.

View File

@@ -0,0 +1,37 @@
------- 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.

39
DEV1.1/TP09/tests.c Normal file
View File

@@ -0,0 +1,39 @@
# include <stdio.h>
# include <stdlib.h>
int main(void) {
int hauteur;
char choix;
int i;
int j;
printf("_______________\n t) Triangle\n c) Carré\n q) Quitter\n Votre choix ? ");
choix = getchar();
while (choix != 'q') {
printf("\n\nHauteur ? ");
scanf("%d", &hauteur);
if (choix == 't') {
for (i = 0; i != hauteur; i++) {
for (j = 0; j != i; j++) {
printf("*");
}
printf("\n");
}
}
else {
for (i = 0; i != hauteur; i++) {
printf("*");
}
printf("\n");
for (i = 0; i != (hauteur - 2); i++) {
printf("*");
for (j = 0; j != (hauteur - 2); j++) {
printf(" ");
}
printf("*\n");
}
}
printf("_______________\n t) Triangle\n c) Carré\n q) Quitter\n Votre choix ? ");
choix = getchar();
}
return EXIT_SUCCESS;
}