X hits on this document

150 views

0 shares

0 downloads

0 comments

44 / 63

Copyright ©2004 Pearson Addison-Wesley. All rights reserved.

8-44

Multidimensional Arrays

A multidimensional array is an array with two or more dimensions.

We will use two-dimensional arrays to represent tables of data, matrices, and other two-dimensional objects.

Thus int x[3][3] would define a three by three matrix that holds integers.

Initialization is bit different

int x[3][3] = {{1,2,3}, {4,5,6}, {7,8,9}};

Both indices starts at 0.

Think of it as x[rows][cols].

x[2][2]=9

x[2][1]=8

x[2][0]=7

x[1][2]=6

x[1][1]=5

x[1][0]=4

x[0][2]=3

x[0][1]=2

x[0][0]=1

Row

Col inside a row

Document info
Document views150
Page views150
Page last viewedWed Dec 07 20:24:12 UTC 2016
Pages63
Paragraphs754
Words4119

Comments