DEV/BUT1/DEV1.1/Tableaux_multidimensionnels/progressions.c

65 lines
1.2 KiB
C
Raw Normal View History

2024-02-01 13:55:03 +01:00
#include <stdlib.h>
#include <stdio.h>
#define ROW_T1 2 // ROW = ligne = à mettre entre les premiers crochets
#define COLUMN_T1 5 // COLMUN = colonne = à mettre entre les seconds crochets
#define ROW_T2 3
#define COLUMN_T2 5
#define ROW_T3 5
#define COLUMN_T3 5
// PROGRAMME T1
int main(void)
{
int tab1[ROW_T1][COLUMN_T1];
for (int i = 0; i < ROW_T1; i++)
{
for (int j = 0; j < COLUMN_T1; j++)
{
tab1[i][j] = j + 1;
printf("%d ", tab1[i][j]);
}
printf("\n");
}
printf("\n");
int tab2[ROW_T2][COLUMN_T2];
int compteur = 1;
for (int i = 0; i < ROW_T2; i++)
{
for (int j = 0; j < COLUMN_T2; j++)
{
tab2[i][j] = compteur;
compteur = compteur + 1;
printf("%d ", tab2[i][j]);
}
printf("\n");
}
printf("\n");
int tab3[ROW_T3][COLUMN_T3];
for (int i = 0; i < ROW_T3; i++)
{
for (int j = 0; j < COLUMN_T3; j++)
{
if (j < i)
{
tab3[i][j] = j + 1;
}
else
{
tab3[i][j] = 0;
}
printf("%d ", tab3[i][j]);
}
printf("\n");
}
}