Ask your own question, for FREE!
Computer Science 20 Online
OpenStudy (anonymous):

[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

OpenStudy (shadowfiend):

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.

OpenStudy (rsmith6559):

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.

OpenStudy (shadowfiend):

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 :)

OpenStudy (rsmith6559):

True. But the assignment IS convert letters to numbers.

OpenStudy (shadowfiend):

Wow. Yeah, totally misread the assignment, excellent point. rsmith is 100% right, make a map from letters to numbers :)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!