Modify Program 8.3, letters.cpp, so that a vector of 26 elements, indexed from 0 to 25, is used to track how many times each letter in the range ’a’–’z’ occurs. To do this, map the character ’a’ to 0, ’b’ to 1,…, and ’z’ to 25. Isolate this mapping in a function CharToIndex whose header is
int CharToIndex(char ch)
// pre: ’a’ <=>
// post: returns 0 for ’a’, 1 for ’b’, ... 25 for ’z’
Note that ’a’ - ’a’ == 0, ’b’ - ’a’ == 1, and ’z’ - ’a’ == 25.)
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here