Programming US $3.2 phone number corresponds to English letters, US $3.2
This is also a very common question. Many similar questions use the same solution. This question means that the numbers on our mobile phones correspond to English letters, this number may correspond to 3, 4, or 0, so when I enter a string of numbers, you need to give all possible English letters for these numbers.
Speaking of this, I believe you will understand that this is actually a full arrangement, but we need to first give a known condition, that is, the numbers correspond to which letters correspond to a few letters, because we need to make a full arrangement, it is necessary to know a range. Therefore, using the thought of full arrangement, we can easily write the following code:
Function declaration:
/* 3.2 phone number corresponds to the English letter */void DutNumberToAlphabet (int *, int); void DutNumberToAlphabet (int *, int, char *, int, int *);
Source code:
Char c [] [10] = {"", "", "ABC", "DEF", "GHI", "JKL", "MNO", "PQRS ", "TUV", "WXYZ"}; // store the characters int total [10] = {0, 0, 3, 3, 3, 3, 3, 4, 3, 4}; // The total number of characters that each array can represent. void DutNumberToAlphabet (int * number, int size) {if (! Number | size <= 0) return; char * result = new char [size]; int * answer = new int [size]; memset (answer, 0, sizeof (int) * size); DutNumberToAlphabet (number, size, result,/* index */0, answer);} void DutNumberToAlphabet (int * number, int size, char * result, int index, int * answer) {if (index = size) {for (int I = 0; I <size; ++ I) cout <c [number [I] [answer [I]; cout <endl;} else {for (answer [index] = 0; answer [index] <total [number [index]; ++ answer [index]) DutNumberToAlphabet (number, size, result, index + 1, answer );}}
Write the first letter of the phone number in English in uppercase.
No
Add English letters to a fixed phone number, such as 0208285259 M
Is there any meaning of transfer?