题目:
电话的号码盘一般可以用于输入字母,如用2可以输入A,B,C,用3可以输入D,E,F等,对于号码5869872可以依次输出其代表的所有的字母组合。
解法一:直接循环法:
#include<iostream>
#include<stdio.h>
using namespace std;
#define TelLength 3
int main()
{
char c[10][10]=
{
"", //0
"", //1
"ABC", //2
"DEF", //3
"GHI", //4
"JKL", //5
"MNO", //6
"PQRS", //7
"TUV", //8
"WXYZ" //9
};
int total[10] = {0,0,3,3,3,3,4,3,4};
int number[TelLength] = {4,2,7};
int answer[TelLength] = {0,0,0};
cout << "427" << "对应的所有英文是:\n";
for(answer[0] = 0; answer[0] < total[number[0]]