array_practice_sol

# array_practice_sol - CS31: Introduction to Computer Science...

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

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; } }

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

View Full Document
CS31: Introduction to Computer Science I Spring 2011 Copyright Brian Choi 2011. All Rights Reserved.
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
Ask a homework question - tutors are online