BUT2/DEV/DEV1.1/TP_Boucles2/q3.c

41 lines
685 B
C
Raw Permalink Normal View History

2023-10-23 13:23:36 +02:00
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int taille;
int x;
printf("Saisissez la taille de la table de multiplication que vous souhaitez : ");
scanf("%d", &taille);
for (x=-2; x<=taille; x+=1){
int y;
printf("\n");
for (y=-2; y<=taille; y+=1){
if (x==-2){
if (y==-2){
printf(" X ");}
if (y==-1){
printf(" | ");}
if (y>=0){
printf("%3d", y);}
}
if (x==-1){
if (y==-2){
printf("---");}
if (y==-1){
printf("-+-");}
if (y>=0){
printf("---");}
}
if (x >= 0){
if (y==-2){
printf("%3d",x);}
if (y==-1){
printf(" | ");}
if (y>=0){
printf("%3d",x*y);}
}
}
}
return EXIT_SUCCESS;
}