DEV/DEV1.1/TP13/tests.c

70 lines
1.1 KiB
C
Raw Permalink Normal View History

2024-10-01 15:08:29 +02:00
# include <stdio.h>
# include <stdlib.h>
int main(void) {
2024-10-06 17:22:04 +02:00
/* Déclaration des tableaux */
int t1[2][5];
int t2[3][5];
int t3[5][5];
int compteur;
/* Remplissage des tableaux */
int i;
int j;
2024-10-01 15:08:29 +02:00
int k;
2024-10-06 17:22:04 +02:00
/* t1 */
for (i = 0; i != 2; i++) {
for (j = 0; j != 5; j++) {
t1[i][j] = j + 1;
}
}
/* t2 */
compteur = 1;
for (i = 0; i != 3; i++) {
for (j = 0; j != 5; j++) {
t2[i][j] = compteur;
compteur++;
}
}
/* t3 */
for (i = 0; i != 5; i++) {
for (j = 0; j != 5; j++) {
if (j >= i) {
t3[i][j] = 0;
2024-10-01 15:08:29 +02:00
}
else {
2024-10-06 17:22:04 +02:00
t3[i][j] = 1 + j;
2024-10-01 15:08:29 +02:00
}
}
}
2024-10-06 17:22:04 +02:00
/* Affichage des tableaux */
for (j = 0; j != 5; j++) {
for (i = 0; i != 17; i++) {
if (i < 5) {
if (j >= 2) {
printf(" ");
}
else {
printf("%.2d ", t1[j][i]);
}
}
/* BAKA */
else if (i == 5 | i == 11) {
printf(" ");
}
else if (i > 5 && i < 11) {
if (j >= 3) {
printf(" ");
}
else {
printf("%.2d ", t2[j][i-6]);
}
}
else {
printf("%.2d ", t3[j][i-12]);
2024-10-01 15:08:29 +02:00
}
}
printf("\n");
2024-10-06 17:22:04 +02:00
}
2024-10-01 15:08:29 +02:00
return EXIT_SUCCESS;
}