array_practice

array_practice - CS31: Introduction to Computer Science I...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS31: Introduction to Computer Science I Spring 2011 Copyright Brian Choi 2011. All Rights Reserved. 1 Two Dimensional Array Practice TA: Brian Choi ([email protected]) Section Webpage: http://www.cs.ucla.edu/~schoi/cs31 Consider the following code: Your job in this exercise is to replace the comment // TODO: Fill in the grid. with code that fills in grid[][] that matches the target output. For example, if the target output is: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 your code will look: for ( int i = 0; i < SIZE; i++) { for ( int j = 0; j < SIZE; j++) { grid[i][j] = i * SIZE + j + 1; } } The only requirement is that your code must work with any positive SIZE value to generate the pattern. You may use a for loop, a while loop, or a combination of several loops. You can also create whatever variables you can. Some problems may not be as easy as they seem… Have fun! 0
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/06/2011 for the course CS 31 taught by Professor Melkanoff during the Spring '00 term at UCLA.

Page1 / 2

array_practice - CS31: Introduction to Computer Science I...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online