Hi,
This question is gonna sound dumb, but say, if I want a 4x5 matrix (ie 4 rows, 5 columns) would I declare it as:
matrix[4][5] or matrix [5][4].
thanks
Hi,
This question is gonna sound dumb, but say, if I want a 4x5 matrix (ie 4 rows, 5 columns) would I declare it as:
matrix[4][5] or matrix [5][4].
thanks
It doesn't matter which way you declare it. You can use it either way. You just have to make your output behave correctly.
int matrix[4][5];
This means to me: "Four columns, five rows." Or as in relation to an xy axes, x = across, y = down, so, 4 wide, by 5 high.
In reality, either way will give you a usable grid, you just have to modify your input and output to use it correctly.
You want "four rows, five columns", so you'd actually use:
int matrix[5][4];
Because generally speaking, you use the first for the X axes/width, second for the Y axes/height, and a third would be Z, assuming you ever decided to use a Z...
Quzah.
Hope is the first step on the road to disappointment.
Conventionally, most people do it like matrix [rows][columns]
> Conventionally, most people do it like matrix [rows][columns]
[edit]
Actually, let me correct myself. It depends on the situation. The most common occurance of my using multi-dimensional arrays is when using a grid for chess or a maze or something similar. When I use it this way, I use the following:
matrix[X][Y]
Just like your screen area: 800x600, 1024x768.
Honestly for my own use, I don't think I've done it any other way. It's easy to see a multi-dimensional array as it relates to my screen, so I don't recall ever doing it any other way.
[/edit]
Quzah.
Last edited by quzah; 04-01-2002 at 06:19 PM.
Hope is the first step on the road to disappointment.
>Conventionally, most people do it like matrix [rows][columns]
Same here.