我自己尝试了输入三个数字的情况,已经正确运行。
#include<stdio.h>
#include<string.h>
void main()
{int i,j,k,m=0;int n0,n1,n2;
char pho[10][5]={{'0'},{'0'},"abc","def","ghi","jkl","mno","pqrs",{'t','u','v'},{'w','x','y','z'}};
char num[11],word[11];
printf("put your number please:\n");
gets(num);
n0=num[0]-48;
n1=num[1]-48;n2=num[2]-48;
printf("%d %d %d\n",n0,n1,n2);
puts(pho[n0]);puts(pho[n1]);puts(pho[n2]);
printf("\n%d\n",strlen(pho[n2]));
for(i=0;i<(int)strlen(pho[n0]);i++)
{word[0]=pho[n0][i];
for(j=0;j<(int)strlen(pho[n1]);j++)
{word[1]=pho[n1][j];
for(k=0;k<(int)strlen(pho[n2]);k++)
{word[2]=pho[n2][k];word[3]='\0';
puts(word);putchar('\n');
m++;
}
}
}
printf("\n the total m=%d\n",m);
}
输入三位数的还可以一个一个的赋值,做嵌套循环,如果输入11个数,一一嵌套的话,那就太庞大了