Developpement/23DEV1.1/TPS1/TP01/07-Boucles/BouclesBis/BoucleBisbis/figure.c

50 lines
950 B
C
Raw Permalink Normal View History

2024-12-09 11:53:11 +01:00
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int i;
int j;
int n;
char ch;
while(ch != 'q'){
printf(" t) Triangle\n c) Carre\n q) Quitter\n ");
printf("Votre choix ?\n");
ch = getchar();
if(ch == 't'){
printf("choisissez la hauteur : ");
scanf("%d",&n);
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(i>j){
printf("*");
}
else{
printf(" ");
}
}
printf("\n");
}
}
if(ch =='c'){
printf("choisissez la hauteur : ");
scanf("%d",&n);
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(i==0 || i == n-1){
printf("*");
}else{
if(j==0 || j==n-1){
printf("*");
}else{
printf(" ");
}
}
}
printf("\n");
}
}
if(ch == 'q'){
printf("Au revoir...\n");
}
}
return EXIT_SUCCESS;
}