array_practice_sol

array_practice_sol - CS31: Introduction to Computer Science...

Info iconThis preview shows pages 1–3. 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 Solutions TA: Brian Choi (schoi@cs.ucla.edu) Section Webpage: http://www.cs.ucla.edu/~schoi/cs31 Problem 1 for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { grid[i][j] = j; } } Problem 2 for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { grid[i][j] = i; } } Problem 3 for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { grid[i][SIZE - j - 1] = i * SIZE + j + 1; } } Problem 4 for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { grid[SIZE - i - 1][j] = i * SIZE + j + 1; } } Problem 5 for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { grid[SIZE - i - 1][SIZE - j - 1] = i * SIZE + j + 1; } } Problem 6 for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { grid[j][i] = i * SIZE + j + 1; } }
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS31: Introduction to Computer Science I Spring 2011 Copyright Brian Choi 2011. All Rights Reserved.
Background image of page 2
Image of page 3
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 / 4

array_practice_sol - CS31: Introduction to Computer Science...

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

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