91 lines
1.7 KiB
C
91 lines
1.7 KiB
C
#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){
|
|
char choix;
|
|
|
|
int hauteur = 0;
|
|
int i;
|
|
int n = 0;
|
|
int etoile;
|
|
|
|
int coter;
|
|
int a;
|
|
int ecart;
|
|
|
|
|
|
|
|
printf("entrer votre choix: ");
|
|
scanf("%c", &choix);
|
|
|
|
if(choix == 't'){
|
|
printf("entrer la hauteur du sapin: ");
|
|
scanf("%d", &hauteur);
|
|
|
|
for (i = 0; i < hauteur; i++){
|
|
|
|
for(etoile = 0; etoile < n; etoile++){
|
|
printf("*");
|
|
}
|
|
|
|
n += 1;
|
|
printf("\n");
|
|
}
|
|
}else if(choix == 'c'){
|
|
printf("entrer la longueur du carre : ");
|
|
scanf("%d", &coter);
|
|
|
|
for(a = 0; a < coter; a++){
|
|
printf("*");
|
|
}
|
|
printf("\n");
|
|
|
|
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");
|
|
|
|
}
|
|
} |