#include <stdio.h>
#include <string.h>
char *p[10] = {"","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};//把所有字符串列出来
int total[10] = {0,0,3,3,3,3,3,4,3,4};//每个数字对应的字符串的位数
int main()
{
char buff[20];
int i;
while(scanf("%s",buff)!=EOF)
{
int len = strlen(buff);
int *number = new int[len];//number存储输入的数字
for(i=0;i<len;i++)
number[i] = buff[i] - '0';
int *answer = new int[len];//answer对应每个数字对应字符串中每个字符的下标
for(i=0;i<len;i++)
answer[i]=0;
while(true)
{
for(i=0;i<len;i++)
{
printf("%c",p[number[i]][answer[i]]);
}
printf("\n");
int k = len - 1;
while(k>=0)
{
if(answer[k] < total[number[k]] - 1)
{
answer[k]++;
break;
}
else
{
answer[k] = 0;
k--;
}
}
if(k<0)
break;
}
printf("\n");
}
return 0;
}
电话号码对应英语单词
最新推荐文章于 2019-10-06 20:23:31 发布