Thread: stupid matrix question

  1. #1
    Unregistered
    Guest

    Unhappy stupid matrix question

    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

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    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.

  3. #3
    Unregistered
    Guest
    Conventionally, most people do it like matrix [rows][columns]

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    > 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.

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >Conventionally, most people do it like matrix [rows][columns]
    Same here.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 11-04-2005, 12:17 AM
  2. Stupid Question
    By digdug4life in forum C++ Programming
    Replies: 22
    Last Post: 05-17-2005, 11:43 AM
  3. stupid, stupid question
    By xelitex in forum C++ Programming
    Replies: 5
    Last Post: 12-22-2004, 08:22 PM
  4. Matrix and vector operations on computers
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 05-11-2004, 06:36 AM
  5. Matrix Reloaded Questions (SPOILERS_
    By Xei in forum A Brief History of Cprogramming.com
    Replies: 73
    Last Post: 10-19-2003, 02:21 PM