73 lines
1.1 KiB
C
73 lines
1.1 KiB
C
|
#include <stdlib.h>
|
||
|
#include <stdio.h>
|
||
|
|
||
|
int i;
|
||
|
int j;
|
||
|
int hauteur;
|
||
|
|
||
|
|
||
|
char triangle(hauteur){
|
||
|
for(i=0;i<=hauteur; i++){
|
||
|
for(j=1;j<=i;j++){
|
||
|
printf("*");
|
||
|
}
|
||
|
printf("\n");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
char carre(hauteur){
|
||
|
for(i=1; i<=hauteur; i++){
|
||
|
if(i==1 || i== hauteur){
|
||
|
for(j=1; j<=hauteur; j++){
|
||
|
printf("*");
|
||
|
}
|
||
|
}
|
||
|
else{
|
||
|
for(j=1; j<=hauteur; j++){
|
||
|
if (j==1 || j == hauteur){
|
||
|
printf("*");
|
||
|
}
|
||
|
else{
|
||
|
printf(" ");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
printf("\n");
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
int main(void){
|
||
|
char choix;
|
||
|
do{
|
||
|
int i=0;
|
||
|
int j=i;
|
||
|
int largeur;
|
||
|
printf("_____________\n");
|
||
|
printf("t) Triangle\n");
|
||
|
printf("c) Carré\n");
|
||
|
printf("q) Quitter\n");
|
||
|
printf("Votre choix ? ");
|
||
|
scanf(" %c", &choix);
|
||
|
printf("\n");
|
||
|
if(choix=='t'){
|
||
|
printf("Hauteur ? ");
|
||
|
scanf("%d", &hauteur);
|
||
|
triangle(hauteur);
|
||
|
}
|
||
|
if(choix=='c'){
|
||
|
printf("Hauteur ? ");
|
||
|
scanf("%d", &hauteur);
|
||
|
carre(hauteur);
|
||
|
}
|
||
|
if(choix=='q'){
|
||
|
printf("\n");
|
||
|
printf("Au revoir !\n");
|
||
|
}
|
||
|
}while(choix!='q');
|
||
|
}
|