I really want to make a program that is accepting integer values and I want that program to print all possible letter combinations assigned to each number or maybe not all. Just like when you type 23, the program should print "ad ae af bd be bf cd ce cf".
How can I do that?
Please help me. Thanks.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35241
7
posted
0
I don't understand how one gets from "23" to the list you mention. Can you describe the algorithm to us?
Im sorry for not explaining my problem very clearly... In your nokia cellphone, there are corresponding letters in every number right?
That's how the number 23 got the letters ad ae af etc... the program will print all possible letter combinations.
These are the letters: number 1: special characters number 2: abc number 3: def number 4: ghi number 5: jkl number 6: mno number 7: pqrs number 8: tuv number 9: wxyz number 0: space
I haven't started yet because I dont know how. Actually I already tried it. I used nesting for loop and if-else but the problem is my program is not printing anything correctly. So my problem is merely everything.
Sounds like a nested loop problem, except the number of nestings isn't fixed. If it were fixed, say at 2 as per your example, there would be a nested loop with the outer one picking up one letter at a time and the inner loop then appending one letter at a time to the one from the outer loop. Now think how to do this using recursion. Put the letters into a 2 dimensional array with the first index being the number and the second index being the letters for that number. This is off the top of my head, of course.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.