Print all possible words from phone keypad using c++
We have to print all possible words that can be formed by pressing those digits of the mobile keyboard using c++.
Approach: In this code, i denotes the index of input and j denotes the index of output.
In base case: if the input array reaches the last position of the input string that means
your work is done. now you will terminate and print that output.
recursive case: you extract the first digit and iterate the string of the keypad array.
now we call recursively to fill the remaining part of the words.
Input format: a numeric string.
Output format: all possible words made by that numeric string.
explanation:
|
1 |
2 |
3 |
|
4 |
5 |
6 |
|
7 |
8 |
9 |
|
* |
0 |
# |
ex- input: 666
output:
MMM
MMN
MMO
MNM
MNN
MNO
MOM
MON
MOO
NMM
NMN
NMO
NNM
NNN
NNO
NOM
NON
NOO
OMM
OMN
OMO
ONM
ONN
ONO
OOM
OON
OOO
Project Files
| .. | ||
| This directory is empty. | ||