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

77 lines
1.2 KiB
C
Raw 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\n");
for (i=0;i<2;i++){
v=0;
for (j=0;j<5;j++){
v++;
t1[i][j]=v;
printf("%d ",t1[i][j]);
} printf("\n");
} printf("\n t2\n");
v=0;
for (i=0;i<3;i++){
for (j=0;j<5;j++){
v++;
t2[i][j]=v;
printf("%2d ",t2[i][j]);
} printf("\n");
} printf("\n t3\n");
v=0;
for (i=0;i<5;i++){
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("\n");
}
printf(" t4\n");
for (i=0;i<5;i++){
for (j=0;j<2;j++){
v=i+1;
t4[i][j]=v;
printf("%d ",t4[i][j]);
} printf("\n");
} printf("\n t5\n");
v=0;
for (i=0;i<5;i++){
v=i+1;
for (j=0;j<3;j++){
t5[i][j]=v;
printf("%2d ",t5[i][j]);
v+=5;
} printf("\n");
} printf("\n t6\n");
v=0;
for (i=0;i<5;i++){
for (j=0;j<5;j++){
if (i<j){
v=i+1;
t6[i][j]=v;
printf("%d ",t6[i][j]);
} else{
v=0;
t6[i][j]=v;
printf("%d ",t6[i][j]);
}
} printf("\n");
}
return 0;
}