two-dimensional arrays

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

show 3 row, 3 column, two diagonal equal

draw a picture to see the position don't make mistake 0 1 2 0 00 01 02 1 10 11 12 2 20 21 22

Declare and instantiate a 3x3 two-dimensional array of integers named tictactoe

int tictactoe[] []= new int [3][3];

element access what is the first element in the first row in array tictactoe

tictactoe [0][0] row position 0 1 2 .... column position 0 1 2 3 ....

tictactoe has been declared to be a two-dimensional array of integers. instantiates a 3*3 two-dimensional array of integers and assign it to tictactoe

tictactoe= new int [3][3];

an expression show the elements of the first row are all equal

tictactoe[0][0]==tictactoe[0][1] && tictactoe[0][0]==tictactoe[0][2]

declaration declare a two dimensional array

String chessboard [ ] [ ]; int tictactoe [] [];

char array

char tictactoe [] []= {{' ',' ',' '},{' ',' ',' '},{' ',' ',' '}}; careful: ' ' not " " add ; in the end

creation you have chessboard, an two dimensional array of strings that has been declared. now instantiates an 8*8 array of strings and assign it to chessboard

chessboard=new String[8][8]; not String chessboard[] []= new String [8][8]; because chessboard has been declared.

declaration-initialization a three demensional array of ints x, with 3row, 2column, each column is an array 4 ints.

int x [] [] [] ={ 3 row } { { } , { } , { } } {3 row, 2 column} { { {},{} } , { {},{} } , { {},{} } } {3 row, 2 column, 4 numbers} { { {5,5,5,5},{5,5,5,5} } , { {7,7,7,7},{7,7,7,7} } , { {8,8,8,8},{8,8,8,8} } }


Kaugnay na mga set ng pag-aaral

Το εσωτερικό του Υπολογιστή

View Set

Algorithmic complexity / Big-O / Asymptotic analysis

View Set