DEV/DEV1.1/TP06:Tableaux/TableauxMultidimensionnels/horizontal.c

75 lines
1.1 KiB
C
Raw Permalink Normal View History

2022-10-18 11:29:05 +02:00
#include <stdio.h>
#include <stdlib.h>
int main() {
int t1[2][5];
int t2[3][5];
int t3[5][5];
int t4[5][2];
int t5[5][3];
int t6[5][5];
int i;
int j;
int v;
printf(" t1 t2 t3 t4 t5 t6\n");
for (i=0;i<5;i++){
v=0;
if (i<2){
for (j=0;j<5;j++){
v++;
t1[i][j]=v;
printf("%d ",t1[i][j]);
}
} else{
printf(" ");
} printf(" ");
v=0;
if (i<3){
v=i*5;
for (j=0;j<5;j++){
v++;
t2[i][j]=v;
printf("%2d ",t2[i][j]);
}
} else{
printf(" ");
} printf(" ");
v=0;
for (j=0;j<5;j++){
if (i>j){
v=j+1;
t3[i][j]=v;
printf("%d ",t3[i][j]);
} else{
v=0;
t3[i][j]=v;
printf("%d ",t3[i][j]);
}
} printf(" ");
v=0;
for (j=0;j<2;j++){
v=i+1;
t4[i][j]=v;
printf("%d ",t4[i][j]);
} printf(" ");
v=i+1;
for (j=0;j<3;j++){
t5[i][j]=v;
printf("%2d ",t5[i][j]);
v+=5;
} printf(" ");
v=0;
for (j=0;j<5;j++){
if (i<j){
v=i+1;
t6[i][j]=v;
printf("%d ",t6[i][j]);
} else{
v=0;
t3[i][j]=v;
printf("%d ",t3[i][j]);
}
} printf("\n");
} printf("\n");
return 0;
}