APL/APL1.1/controle_machine/reticule.c
2021-10-19 14:51:16 +02:00

44 lines
845 B
C

#include<stdio.h>
#include<stdlib.h>
int main(int argc, char * argv[]) {
int nb_square;
printf("Veuillez indiquer le nombre de carrés : ");
scanf("%d", &nb_square);
for (int i = 0; i < nb_square; i++) {
for (int i2 = 0; i2 < i; i2++) printf("| ");
printf("+");
for (int i2 = 0; i2 < ((nb_square-i)*2)-1; i2++) {
printf("--");
}
printf("+");
for (int i2 = 0; i2 < i; i2++) printf(" |");
printf("\n");
}
for (int i = 0; i < nb_square; i++) printf("| ");
for (int i = 0; i < nb_square; i++) printf(" |");
printf("\n");
for (int i = nb_square-1; i >= 0; i--) {
for (int i2 = 0; i2 < i; i2++) printf("| ");
printf("+");
for (int i2 = 0; i2 < ((nb_square-i)*2)-1; i2++) {
printf("--");
}
printf("+");
for (int i2 = 0; i2 < i; i2++) printf(" |");
printf("\n");
}
return EXIT_SUCCESS;
}