Matrici (array bidimensionali) Un array bidimensionale, anche detto matrice, è una variabile strutturata tale che:
int C[4][3];
float f[M][N];
char b[2][3]={{'a', 'b', 'c'},{'d', 'e', 'f'}}
int A[ ][3]= { 1,2,3,4,5,6,7,8,9 };
int matrice[3][3] = {{2, 4, 6}, {5, 1, 8}, {4, 3, 0}};
matrice[0][2]; // -> mi riferisco al valore 6
int matrice[3][3] = {{2, 4, 6}, {5, 1, 8}, {4, 3, 0}};
cin >> matrice[0][2];
// inserisco un valore nella posizione 0,2
int matrice[3][3] = {{2, 4, 6}, {5, 1, 8}, {4, 3, 0}};
cout << matrice[1][2]; //Output: 8
int matrice[3][3] = {{2, 4, 6}, {5, 1, 8}, {4, 3, 0}};
for(int i=0; i<3; i++) {
for(int j=0; j<3; j++) {
cout << matrice[i][j] << " ";
}
cout << endl;
}
int matrice[3][3];
for(int i=0; i<3; i++) {
for(int j=0; j<3; j++) {
cin >> matrice[i][j];
}
}