{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture17

# lecture17 - CS111 Intro to Computer Science Lecture 17 Data...

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

CS111: Slides for Prof. Steinberg ʼ s lecture 1 Lecture 17 CS111: Intro to Computer CS111: Intro to Computer Science Science Lecture 17 Data in Objects Linked Lists

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

View Full Document
CS111: Slides for Prof. Steinberg ʼ s lecture 2 Lecture 17 Review: 2-Dimensional arrays Review: 2-Dimensional arrays Suppose you have a class of 3 students, each student takes 5 quizzes, and you want to get The sum over all students of the scores on quiz 1, 2, 3, 4, and 5 The sum over all quizzes of the scores of students 1, 2, and 3
CS111: Slides for Prof. Steinberg ʼ s lecture 3 Lecture 17 2-Dimensional arrays 2-Dimensional arrays Like 1-D arrays: separately create Variable to refer to the array int [ ] [ ] scores The array itself scores = new int [5] [3] A 2-D array is an array of 1-D arrays

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

View Full Document
CS111: Slides for Prof. Steinberg ʼ s lecture 4 Lecture 17 length length scores. length is number of rows scores[r]. length is length of row r, I.e. # of columns Note no ( ) after length, unlike eg String word = “abc”; … word.length ( )
CS111: Slides for Prof. Steinberg ʼ s lecture 5 Lecture 17 Nested Loops Nested Loops To think about where to put things in a program with nested loops, ask how many times does it happen To sum the columns of a 2-D array, where do you set sum=0?

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.

{[ snackBarMessage ]}