APL/APL1.1/TP15/decoupage.c

46 lines
793 B
C
Raw Normal View History

2021-10-18 16:28:46 +02:00
#include<stdio.h>
#include<stdlib.h>
#define SIZE 10
void drawTriangle() {
for (int i = 0; i <= SIZE; i++) {
for (int i2 = SIZE-i; i2 > 0; i2--) printf(" ");
for (int i2 = 0; i2 < i*2-1; i2++) printf("* ");
printf("\n");
}
}
void drawSquare() {
for (int x = 0; x < SIZE; x++) {
for (int y = 0; y < SIZE; y++) {
printf("* ");
}
printf("\n");
}
}
int showMenu() {
int choice;
puts("Que voulez vous dessiner ?");
puts("1. Carré");
puts("2. Triangle");
2021-11-09 13:53:20 +01:00
puts("3. Quitter");
2021-10-18 16:28:46 +02:00
scanf("%d", &choice);
return choice;
}
int main(int argc, char * argv[]) {
2021-11-09 13:53:20 +01:00
int choice;
do {
choice = showMenu();
if (choice == 1) drawSquare();
else if (choice == 2) drawTriangle();
else if (choice != 3) puts("Choix incorrect.");
} while (choice != 3);
2021-10-18 16:28:46 +02:00
return EXIT_SUCCESS;
}