APL/APL1.1/Dev1.1/Fonctions/decoupage.c
2021-11-30 15:07:19 +01:00

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;
}