DECLARATION:
-in general, a multidimensional array definition can be written as..
data-type variable-name [subscript1][subscript2]
ex. int cards[4][12];
------------------------------------
INITIALIZATION:
-like the one-dimensional arrays, they can be initialized on their definition
-the syntax underscores that it is an array of arrays
ex. int cards[4][12] = { {arg1, arg2,...argn}, {arg1, arg2,...argn} };
-only size of the first dimension can be excluded
ex. float matrix [][3] = { {1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0} };
------------------------------------
PROCESSING:
-still, operations must be carried out on an element-by-element basis.
ex.1
matrix[0][0] = 1.0;
matrix[0][1] = 0.0;
matrix[0][2] = 1.0;
ex.2
for(i=0; o<3; i++){
for(j=0; j<3; j++){
printf("%f", matrix[i][j]);
}
printf("\n");
}
Wednesday, February 24, 2010
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment