88 lines
1.1 KiB
C
88 lines
1.1 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
int choice;
|
|
int x;
|
|
int menu()
|
|
{
|
|
printf("--------------\n");
|
|
printf(" 1) Triangle\n");
|
|
printf(" 2) Carré\n");
|
|
printf(" 3) Quitter\n");
|
|
printf("Votre choix ?");
|
|
scanf("%d", &choice);
|
|
|
|
return choice;
|
|
}
|
|
int carree()
|
|
{
|
|
int c,h,cpt,cpt2;
|
|
c=0;
|
|
printf ("Hauteur ?");
|
|
scanf ("%d", &h);
|
|
while(c < h)
|
|
{
|
|
printf("*");
|
|
c=c+1;
|
|
}
|
|
c=0;
|
|
printf("\n");
|
|
h=h-2;
|
|
while(cpt < h)
|
|
{
|
|
printf("*");
|
|
while(cpt2 < h)
|
|
{
|
|
printf(" ");
|
|
cpt2=cpt2+1;
|
|
}
|
|
printf("*\n");
|
|
cpt=cpt+1;
|
|
cpt2=0;
|
|
}
|
|
h=h+2;
|
|
while(c < h)
|
|
{
|
|
printf("*");
|
|
c=c+1;
|
|
}
|
|
printf("\n");
|
|
}
|
|
int triangle()
|
|
{
|
|
int h,cpt,c,i;
|
|
cpt=0;
|
|
printf ("Hauteur ?");
|
|
scanf("%d", &h);
|
|
while(cpt < h)
|
|
{
|
|
while(c <= i)
|
|
{
|
|
printf("*");
|
|
c=c+1;
|
|
}
|
|
i=i+1;
|
|
printf("\n");
|
|
cpt=cpt+1;
|
|
c=0;
|
|
}
|
|
}
|
|
int main(int argc, char const *argv[])
|
|
{
|
|
choice=menu(choice);
|
|
|
|
if(choice == 1)
|
|
{
|
|
choice=triangle();
|
|
}
|
|
if(choice == 2)
|
|
{
|
|
choice=carree();
|
|
}
|
|
if(choice == 3)
|
|
{
|
|
return EXIT_SUCCESS;
|
|
}
|
|
printf("%d", choice);
|
|
return EXIT_SUCCESS;
|
|
}
|