Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9039127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:39:32+00:00 2026-06-16T09:39:32+00:00

I have an 8×8 matrix, like this: char matrix[8][8]; Also, I have an array

  • 0

I have an 8×8 matrix, like this:

char matrix[8][8];

Also, I have an array of 64 elements, like this:

char array[64];

Then I have drawn the matrix as a table, and filled the cells with numbers, each number being incremented from left to right, top to bottom.

If I have, say, indexes 3 (column) and 4 (row) into the matrix, I know that it corresponds to the element at position 35 in the array, as it can be seen in the table that I’ve drawn. I believe there is some sort of formula to translate the 2 indexes of the matrix into a single index of the array, but I can’t figure out what it is.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T09:39:33+00:00Added an answer on June 16, 2026 at 9:39 am

    The way most languages store multi-dimensional arrays is by doing a conversion like the following:

    If matrix has size, n (rows) by m (columns), and we’re using "row-major ordering" (where we count along the rows first) then:

    matrix[ i ][ j ] = array[ i*m + j ].

    Here i goes from 0 to (n-1) and j from 0 to (m-1).

    So it’s just like a number system of base ‘m’. Note that the size of the last dimension (here the number of rows) doesn’t matter.


    For a conceptual understanding, think of a (3×5) matrix with ‘i’ as the row number, and ‘j’ as the column number. If you start numbering from i,j = (0,0) --> 0. For ‘row-major’ ordering (like this), the layout looks like:

               |-------- 5 ---------|
      Row      ______________________   _ _
       0      |0    1    2    3    4 |   |
       1      |5    6    7    8    9 |   3
       2      |10   11   12   13   14|  _|_
              |______________________|
    Column     0    1    2    3    4 
    

    As you move along the row (i.e. increase the column number), you just start counting up, so the Array indices are 0,1,2.... When you get to the second row, you already have 5 entries, so you start with indices 1*5 + 0,1,2.... On the third row, you have 2*5 entries already, thus the indices are 2*5 + 0,1,2....

    For higher dimension, this idea generalizes, i.e. for a 3D matrix L by N by M:

    matrix[ i ][ j ][ k ] = array[ i*(N*M) + j*M + k ]

    and so on.


    For a really good explanation, see: http://www.cplusplus.com/doc/tutorial/arrays/; or for some more technical aspects: http://en.wikipedia.org/wiki/Row-major_order

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php array like this: [ ['url_id' => 2191238, 'time_spent' => 41],
I have a matrix with some NA that I'd like to format and then
I have an array char[] Select = {'A','B','C','D','E','F','G','H','I','J'} and each element in this array
I have an array in php like this : Array ( [0] => Array
Have dict like: mydict= {'a':[],'b':[],'c':[],'d':[]} list like: log = [['a',917],['b', 312],['c',303],['d',212],['a',215],['b',212].['c',213],['d',202]] How do i
i have some xaml files that include text, this text is in paterns, like
I have this string: 525,294,475,215,365,745 and i need to remove 475..and comma. and if
I have two tables with like below codes: Table: Accounts id | username |
I have this issue when I would like to go the Game Over screen.
Here I have one file testdec.txt . In this File Contents are like below.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.