write a program that uses a one dimension to do a table look-up learn about parallel arrays

17
Table Look-Up Using One Dimensional Arrays Lesson xx

Upload: jean-owen

Post on 26-Dec-2015

218 views

Category:

Documents


1 download

TRANSCRIPT

  • Slide 1
  • Slide 2
  • Slide 3
  • Write a program that uses a one dimension to do a table look-up Learn about parallel arrays
  • Slide 4
  • 1.Given the following table of point values for each letter of the alphabet ^ a b c d e f g h i j k l m n o p q r s t u v w x y z 0, 2, 3, 5, 7, 6, 5, 4, 5, 7, 8, 5, 4, 5, 3, 5, 6, 5, 9, 1, 2, 3, 2, 4, 7,8,5 2.Read in a sentence 2.Determine the point value of the sentence by adding together the value of each letter.
  • Slide 5
  • Table ^ a b c d e f g h i j k l m n o p q r s t u v w x y z 0, 2, 3, 5, 7, 6, 5, 4, 5, 7, 8, 5, 4, 5, 3, 5, 6, 5, 9, 1, 2, 3, 2, 4, 7, 8,5 Sentence h i j o e 5 7 8 5 6 Point value of sentence = 5 + 7 + 8 + 5 + 6 = 31
  • Slide 6
  • int j, k; for (j = 0; j < length; j++) { for (k = 0; k < 27; k++) { if (s[j] == alphabet [k]) { acc += letVal[k]; break; } } }
  • Slide 17
  • cout