DEV/DEV1.1/TP09/tests.c

40 lines
794 B
C
Raw Normal View History

2024-09-24 15:03:19 +02:00
# 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;
}