{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

L13_multi_dim_arrays

# L13_multi_dim_arrays - Two Two-Dimensional Arrays...

This preview shows pages 1–9. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Two Two-Dimensional Arrays Dimensional Arrays • 2-D Arrays • 2-D Array Processing • Passing 2-D Arrays EECS 183 University of Michigan Lecture 13– Multi-dimensional arrays ML Dorf • Arrays of Arrays Arrays Arrays • Implements list or vector data • Basic array is one-dimensional – x x x x x x x x x x … – 0 1 2 3 4 5 6 7 8 … EECS 183 University of Michigan Lecture 13– Multi-dimensional arrays ML Dorf Two Two-Dimensional Arrays Dimensional Arrays • Implement table data • Example uses: – Matrix – Image – Game board – Spreadsheet EECS 183 University of Michigan Lecture 13– Multi-dimensional arrays ML Dorf scores [ 0 ] scores [ 1 ] • review: const int NUMSCORES = 50; int scores [NUMSCORES ]; • a 1 a 1-D array of int D array of int EECS 183 University of Michigan Lecture 13– Multi-dimensional arrays ML Dorf scores [ 49 ] • • scores • • a 2 a 2-D array of char D array of char O X X X X O EECS 183 University of Michigan Lecture 13– Multi-dimensional arrays ML Dorf O O X (tic-tac-toe) char ticTacToe[3][3]; a 2 a 2-D array of char D array of char char tictactoe[3][3]; char tictactoe[3][3]; Place an ‘X’ in the middle tictactoe[1][1] = ‘X’; // really ttt[row][col] 0 1 2 ws EECS 183 University of Michigan Lecture 13– Multi-dimensional arrays ML Dorf (tic-tac-toe) 1 2 rows cols X a 2 a 2-D array of char D array of char char tictactoe[3][3]; char tictactoe[3][3]; t[0][0] Place an ‘X’ in the top-middle tictactoe[0][1] = ‘X’; // really ttt[row][col] 0 1 2 ws t[0][1] t[0][2] EECS 183 University of Michigan Lecture 13– Multi-dimensional arrays ML Dorf ttt[0][0] (tic-tac-toe) 1 2 rows cols ttt[0][1] ttt[0][2] ttt[1][0] ttt[1][1] ttt[1][2] ttt[2][0] ttt[2][1] ttt[2][2] Nothing that says we can't do … Nothing that says we can't do … t[0][2] Place an ‘X’ in the top-middle tictactoe[1][2] = ‘X’; // really ttt[row][col] 0 1 2 ws t[1][2] t[2][2] EECS 183 University of Michigan Lecture 13– Multi-dimensional arrays ML Dorf ttt[0][2] (tic-tac-toe) 2 1 rows cols ttt[1][2] ttt[2][2] ttt[0][01 ttt[1][1] ttt[2][1] ttt[0][0] ttt[1][0] ttt[2][0] But by convention, we typically do:...
View Full Document

{[ snackBarMessage ]}

### Page1 / 26

L13_multi_dim_arrays - Two Two-Dimensional Arrays...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online