5. On the standard Touch Tone telepone dial, the digits are mapped onto the alph
ID: 3532124 • Letter: 5
Question
5. On the standard Touch Tone telepone dial, the digits are mapped onto the alphabet ( minimaze the lettersQ and Z) as shown in the diagram below: 1, ABC2, DEF3, GHI4, JKL5, MNO6, PRS7, TUV8, WXY9, *, 0, #.
In order to make their phone numbers more memorable, service providers to find numbers that spell out some word (called a mnemonics) appropriate to their business that makes that phone number easier to remember. For example the phone number for a recorded time-of-day message in some localities 637-8687 (NERVOUS)
Image tha you have just been hired by a local telephone company. write a function ListMnemonics that will generate all possible combinations that correspond to a given number, represented as a digits. For example, if you call
ListMnemonics(*723*)
Your program should generate th following 27 possible letter combination that correspond to that prefix:
FAD TWO FCD KAD KKD KKO RCD SAD EMG NCD
FAX THE FCE KAE EEE RCE SAX EHE DHE NCE
FAF THF FCF RAP KRF KAP RCF SAF SHF NCY
This question asks you to simply implement ListMnemonics(char *str) function, and other subsidiary or utility functions (if any). In this assignment, however, we ask you to implement a mnemonics library which exports ListMnemonics(char *str); in mnemonics.h and implement it along with other subsidiary and utility functions (if any) in mnemonics.c.
Once your library is implemented, then you are asked to implement a client/driver program (e.g., driver.c) that gets different strings from the command line and calls the ListMnemonics() function for each string. Your driver program should check each string and make sure each string contains only digits between 2 and 9; otherwise, gives an error msg for that string.
If we run your program as follows
> program 723 41267 3a5b81
Your program should generate the following outputs
Mnemonics for 723 are:
PAD PBD PCD RAD RBD RCD .... (as given in the textbook)
Mnemonics for 412 are:
None, 412 contains a digit 1
Mnemonics for 412 are:
None, 3a5 contains at least one alphabetic character
Explanation / Answer
Hi friend... This is really a simple algorithm if you think about. You have three variables that change from a numeric range.
Here is the pseudo code
for(i = first char in list; i <= last char in list; i++){
for(j = first char in second list; i <= last char in second list; j++){
for(k = first char in third list; k <= last char in third list; k++){
// do something... Print for example.
These loops will account for the changing of each variable.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.