[C++] In a cell phone keypad each num key (2-9) corresponds to 3 or 4 letters. Create a dictionary that contains num as the key and those letters as the value. Write a function reads a string of 7 letters and converts to numbers
Which part of this confuses you? Generally in this case you'll want a dictionary that maps numbers to an array of chars, or to a list (e.g., std::vector) of chars.
If possible, you'd probably be better off mapping the letters back to the numbers. That way you'd have unique keys mapped to a single value.
Well, the problem there is that if someone presses a key and you want to find the associated letters, the reverse map won't help you :)
True. But the assignment IS convert letters to numbers.
Wow. Yeah, totally misread the assignment, excellent point. rsmith is 100% right, make a map from letters to numbers :)
Join our real-time social learning platform and learn together with your friends!