OK
2023-05-07 20:03:31
发布于:重庆
64阅读
0回复
0点赞
#include <stdio.h>
// d-2
const char *pwd[] = { "", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
const int dlen[] = {0, 0, 3, 3, 3, 3, 3, 4, 3, 4};
int cnt[10], t;
int st[10], fcnt[10];
int main() {
int n;
scanf("%d", &n);
t = 1;
for (int i=1; i<=n; i++) {
scanf("%d", &st[i]);
t *= dlen[st[i]];
}
printf("%d\n", t);
while (1) {
for (int i=1; i<=n; i++) {
putchar(pwd[st[i]][fcnt[i]]);
}
putchar('\n');
for (int i=n; i>=1; i--) {
fcnt[i]++;
if (i==1 && fcnt[i]==dlen[st[i]]) goto END;
if (fcnt[i] == dlen[st[i]]) fcnt[i] = 0;
else break;
}
}
END:
return 0;
}
这里空空如也
有帮助,赞一个