73 lines
982 B
C
73 lines
982 B
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
|
||
|
int choix(){
|
||
|
char x;
|
||
|
printf("____________\n t) triangle\n c) Carre\n q) Quitter\nVotre choix ? :");
|
||
|
scanf("%c",&x);
|
||
|
if (x=='t')
|
||
|
{
|
||
|
return 1;
|
||
|
}
|
||
|
if (x=='c')
|
||
|
{
|
||
|
return 2;
|
||
|
}
|
||
|
if (x=='q')
|
||
|
{
|
||
|
return 0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void triangle(int hauteur){
|
||
|
int maxj=1;
|
||
|
for(int i=1;i<=hauteur;i++){
|
||
|
for(int j=1;j<=maxj;j++){
|
||
|
printf("*");
|
||
|
}
|
||
|
printf("\n");
|
||
|
maxj+=1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void carre(int hauteur){
|
||
|
for(int i=1;i<=hauteur;i++){
|
||
|
if((i==1)||(i==hauteur)){
|
||
|
for(int j=1;j<=hauteur;j++){
|
||
|
printf("*");
|
||
|
}
|
||
|
}
|
||
|
else{
|
||
|
printf("*");
|
||
|
for(int j=1;j<hauteur-1;j++){
|
||
|
printf(" ");
|
||
|
}
|
||
|
printf("*");
|
||
|
}
|
||
|
printf("\n");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int main(int argc, char const *argv[]){
|
||
|
int y=0;
|
||
|
int aFaire=choix();
|
||
|
if (aFaire==1)
|
||
|
{
|
||
|
printf("Hauteur ?: ");
|
||
|
getchar();
|
||
|
scanf("%d",&y);
|
||
|
triangle(y);
|
||
|
}
|
||
|
if (aFaire==2)
|
||
|
{
|
||
|
printf("Hauteur ?: ");
|
||
|
getchar();
|
||
|
scanf("%d",&y);
|
||
|
carre(y);
|
||
|
}
|
||
|
if (aFaire==0)
|
||
|
{
|
||
|
printf("Aurevoir...");
|
||
|
}
|
||
|
return 0;
|
||
|
}
|