1 / 16

int matrixArray[12]

int matrixArray[12]. The elements in an array are stored in a series of contiguous memory locations, each holding a piece of integer data. Often we represent data in different structures, such as a Matrix. Why? Picture files (gifs, bitmaps or jpegs) Area Plots. Note!

arista
Download Presentation

int matrixArray[12]

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. intmatrixArray[12] The elements in an array are stored in a series of contiguous memory locations, each holding a piece of integer data. Often we representdata in different structures, such as a Matrix. • Why? • Picture files (gifs, bitmaps or jpegs) • Area Plots Note! It is still a linear array of integers in our code. But we want to treat it as a Matrix.

  2. intmatrixArray[12]

  3. intmatrixArray[12] Row = 3 Coln = 4

  4. intmatrixArray[12] Row = 3 Coln = 4

  5. intmatrixArray[12] Row = 3 Coln = 4

  6. intmatrixArray[12] intgetIndex(intr, intc, intcoln, introw) Row = 3 Coln = 4 Index = (r * coln)

  7. intmatrixArray[12] intgetIndex(intr, intc, intcoln, introw) Row = 3 Coln = 4 Index = (r * coln)

  8. intmatrixArray[12] intgetIndex(intr, intc, intcoln, introw) Row = 3 Coln = 4 Index = (r * coln) (0 * 4) = 0

  9. intmatrixArray[12] intgetIndex(intr, intc, intcoln, introw) Row = 3 Coln = 4 Index = (r * coln) (0 * 4) = 0 (1 * 4) = 4

  10. intmatrixArray[12] intgetIndex(intr, intc, intcoln, introw) Row = 3 Coln = 4 Index = (r * coln) (0 * 4) = 0 (1 * 4) = 4 (2 * 4) = 8

  11. intmatrixArray[12] intgetIndex(intr, intc, intcoln, introw) Row = 3 Coln = 4 Index = (r * coln) + c (0 * 4) = 0 (1 * 4) = 4 (2 * 4) = 8

  12. intmatrixArray[12] intgetIndex(intr, intc, intcoln, introw) Row = 3 Coln = 4 Index = (r * coln) + c (0 * 4) = 0 + 1 = 1 (1 * 4) = 4 + 1 = 5 (2 * 4) = 8 + 1 = 9

  13. intmatrixArray[12] intgetIndex(intr, intc, intcoln, introw) Row = 3 Coln = 4 Index = (r * coln) + c (0 * 4) = 0 + 2 = 2 (1 * 4) = 4 + 2 = 6 (2 * 4) = 8 + 2 = 10

  14. intmatrixArray[12] void getRowColn(intindex,intcoln, introw, int&r, int&c) Row = 3 Coln = 4

  15. intmatrixArray[12] void getRowColn(intindex,intcoln, introw, int&r, int&c) Row = 3 Coln = 4 r = i / coln; c = i % coln; r = 6 / 4 = 1 c = 6 % 4 = 2

  16. intmatrixArray[12] Row = 3 Coln = 4

More Related