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 *? ; 8 ) * ‡ ( ; 4 8 5 ) ; 5 * † 2 : * ‡ ( ; 4 9 5 6 * 2 ( 5 * – 4 ) 8 ¶8 * ; 4 0 6 9 2 8 5 ) ; ) 6 † 8 ) 4 ‡ ‡ ; 1 ( ‡ 9 ; 4 8 0 8 1 ; 8 : 8 ‡1 ; 4 8 † 8 5 ; 4 ) 4 8 5 † 5 2 8 8 0 6 * 8 1 ( ‡ 9 ; 4 8 ; ( 8 8 ; 4 (‡ ? 3 4 ; 4 8 ) 4 ‡ ; 1 6 1 ; : 1 8 8 ; ‡ ? ;833;26419‡ 16) 16*13512611(10† 818069525:434?3¶2–1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 ( 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