2024-09-23 15:00:19 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
/*int main(void){
|
|
|
|
int hauteur = 0;
|
|
|
|
int i;
|
|
|
|
int espace;
|
|
|
|
int etoile;
|
|
|
|
int n = 1;
|
|
|
|
int x = 0;
|
|
|
|
|
|
|
|
printf("entrer la hauteur du sapin: ");
|
|
|
|
scanf("%d", &hauteur);
|
|
|
|
|
|
|
|
for (i = 0; i < hauteur; i++){
|
|
|
|
|
|
|
|
for(espace = 0; espace < hauteur - 1 - i; espace++){
|
|
|
|
printf(" ");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for(etoile = 0; etoile < n; etoile++){
|
|
|
|
printf("*");
|
|
|
|
}
|
|
|
|
n += 2;
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
int main(void){
|
2024-10-14 13:54:43 +02:00
|
|
|
char choix;
|
|
|
|
|
2024-09-23 15:00:19 +02:00
|
|
|
int hauteur = 0;
|
|
|
|
int i;
|
|
|
|
int n = 0;
|
|
|
|
int etoile;
|
|
|
|
|
2024-10-14 13:54:43 +02:00
|
|
|
int coter;
|
|
|
|
int a;
|
|
|
|
int ecart;
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-09-23 15:00:19 +02:00
|
|
|
printf("entrer votre choix: ");
|
2024-10-14 13:54:43 +02:00
|
|
|
scanf("%c", &choix);
|
2024-09-23 15:00:19 +02:00
|
|
|
|
2024-10-14 13:54:43 +02:00
|
|
|
if(choix == 't'){
|
2024-09-23 15:00:19 +02:00
|
|
|
printf("entrer la hauteur du sapin: ");
|
|
|
|
scanf("%d", &hauteur);
|
|
|
|
|
|
|
|
for (i = 0; i < hauteur; i++){
|
|
|
|
|
|
|
|
for(etoile = 0; etoile < n; etoile++){
|
|
|
|
printf("*");
|
|
|
|
}
|
|
|
|
|
2024-10-14 13:54:43 +02:00
|
|
|
n += 1;
|
2024-09-23 15:00:19 +02:00
|
|
|
printf("\n");
|
|
|
|
}
|
2024-10-14 13:54:43 +02:00
|
|
|
}else if(choix == 'c'){
|
|
|
|
printf("entrer la longueur du carre : ");
|
|
|
|
scanf("%d", &coter);
|
|
|
|
|
|
|
|
for(a = 0; a < coter; a++){
|
|
|
|
printf("*");
|
|
|
|
}
|
|
|
|
printf("\n");
|
2024-09-23 15:00:19 +02:00
|
|
|
|
2024-10-14 13:54:43 +02:00
|
|
|
for(a = 0; a < (coter - 2); a++){
|
|
|
|
printf("*");
|
|
|
|
for(ecart = 0; ecart < (coter - 2); ecart++){
|
|
|
|
printf(" ");
|
|
|
|
}
|
|
|
|
printf("*");
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
for (a = 0; a < coter; a++){
|
|
|
|
printf("*");
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
|
|
|
|
}else if(choix == 'q'){
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}else{
|
|
|
|
printf("caractère non reconues\n");
|
|
|
|
|
|
|
|
}
|
2024-09-23 15:00:19 +02:00
|
|
|
}
|