#include <iostream>
#include <string>
using namespace std;

char strSets[10][5] =


{
"",
"",
"abc",
"def",
"ghi",
"jkl",
"mno",
"pqrs",
"tuv",
"wxyz"
};


int count[10] =
{0, 0, 3, 3, 3, 3, 3, 4, 3, 4};

void Display1(int num[], int counts)


{

int index[10] =
{0};
while(true)

{
int i;
for(i = 0; i < counts; i++)
cout<<strSets[num[i]][index[i]];
cout<<endl;

int temp = counts - 1;
while(temp >= 0)

{
if(index[temp] < count[num[temp]] - 1)

{
index[temp]++;
break;
}
else

{
index[temp] = 0;
temp--;
}
}
if(temp < 0)

{
break;
}
}
};

void display2(int num[], int temp[], int index, int counts)


{
if(counts == index)

{
int i;
for(i = 0; i < counts; i++)
cout<<strSets[num[i]][temp[i]];
cout<<endl;
return;
}

for(temp[index] = 0; temp[index] < count[num[index]]; temp[index]++)

{
display2(num, temp, index + 1, counts);
}
};

void main()


{

int z[4] =
{2, 3, 4, 5};
int j;
Display1(z, 4);
cin>>j;

int temp[10] =
{0};
display2(z, temp, 0, 4);
cin>>j;
}
转载于:https://www.cnblogs.com/jackill/archive/2009/07/05/1517038.html