DOC PREVIEW
Stanford CS 106A - Simple Arrays

This preview shows page 1-2-24-25 out of 25 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 25 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Simple ArraysOnce upon a time . . .CryptogramsPoe’s Cryptogram PuzzleSlide 5Introduction to ArraysDeclaring an Array VariableAn Example of Array DeclarationArray SelectionCycling through Array ElementsExercise: Summing an ArrayHuman-Readable Index ValuesArrays and GraphicsA Larger Sample RunThe YarnPattern ProgramSlide 16A Digression on the ++ OperatorInternal Representation of ArraysPassing Arrays as ParametersThe ReverseArray ProgramUsing Arrays for TabulationImplementation StrategyCountLetterFrequenciesSlide 24The EndSimple ArraysEric RobertsCS 106AFebruary 10, 2010Once upon a time . . .Cryptograms•A cryptogram is a puzzle in which a message is encoded by replacing each letter in the original text with some other letter. The substitution pattern remains the same throughout the message. Your job in solving a cryptogram is to figure out this correspondence.•In this story, Poe describes the technique of assuming that the most common letters in the coded message correspond to the most common letters in English, which are E, T, A, O, I, N, S, H, R, D, L, and U. •One of the most famous cryptograms was written by Edgar Allan Poe in his short story “The Gold Bug.”Edgar Allan Poe (1809-1849)QuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.Poe’s Cryptogram Puzzle5 3 ‡ ‡ † 3 0 5 ) ) 6 * ; 4 8 2 6 ) 4 ‡ • ) 4 ‡ ) ; 8 0 6 * ; 4 8 † 8 ¶6 0 ) ) 8 5 ; 1 ‡ ( ; : ‡ * 8 † 8 3 ( 8 8 ) 5 * † ; 4 6 ( ; 8 8 * 9 6 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2 E 5 ) ; ) 6 † E ) 4 ‡ ‡ ; 1 ( ‡ 9 ; 4 E 0 E 1 ; E : E ‡1 ; 4 E † E 5 ; 4 ) 4 E 5 † 5 2 E E 0 6 * E 1 ( ‡ 9 ; 4 E ; ( E E ; 4 (‡ ? 3 4 ; 4 E ) 4 ‡ ; 1 6 1 ; : 1 E E ; ‡ ? ;5 3 ‡ ‡ † 3 0 5 ) ) 6 * T H E 2 6 ) H ‡ • ) H ‡ ) T E 0 6 * T H E † E ¶6 0 ) ) E 5 T 1 ‡ ( T : ‡ * E † E 3 ( E E ) 5 * † T H 6 ( T E E * 9 6 *? T E ) * ‡ ( T H E 5 ) T 5 * † 2 : * ‡ ( T H 9 5 6 * 2 ( 5 * – H ) E ¶E * T H 0 6 9 2 E 5 ) T ) 6 † E ) H ‡ ‡ T 1 ( ‡ 9 T H E 0 E 1 T E : E ‡1 T H E † E 5 T H ) H E 5 † 5 2 E E 0 6 * E 1 ( ‡ 9 T H E T ( E E T H (‡ ? 3 H T H E ) H ‡ T 1 6 1 T : 1 E E T ‡ ? TA G O O D G L A S S I N T H E B I S H O P S H O S T E L I N T H E D E VI L S S E A T F O R T Y O N E D E G R E E S A N D T H I R T E E N M I NU T E S N O R T H E A S T A N D B Y N O R T H M A I N B R A N C H S E VE N T H L I M B E A S T S I D E S H O O T F R O M T H E L E F T E Y E OF T H E D E A T H S H E A D A B E E L I N E F R O M T H E T R E E T H RO U G H T H E S H O T F I F T Y F E E T O U TSimple ArraysIntroduction to Arrays•An array is a collection of individual data values with two distinguishing characteristics:•The individual values in an array are called elements. The type of those elements (which …


View Full Document

Stanford CS 106A - Simple Arrays

Download Simple Arrays
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Simple Arrays and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Simple Arrays 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?