分类: Java
2016-06-14 23:36:49
package com.qiyi.biwangshen;
public class Solution {
char[][] c = { {}, {}, { 'A', 'B', 'C' }, { 'D', 'E', 'F' }, { 'G', 'H', 'I' }, { 'J', 'K', 'L' },
{ 'M', 'N', 'O' }, { 'P', 'Q', 'R', 'S' }, { 'T', 'U', 'V' }, { 'W', 'X', 'Y', 'Z' } };
int[] total = { 0, 0, 3, 3, 3, 3, 3, 4, 3, 4 };
public void solution(int len, int[] number, int[] answer) {
while (true) {
for (int i = 0; i < len; i++) {
System.out.println(c[number[i]][answer[i]]);
}
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;
}
}
}
package com.qiyi.biwangshen;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Solution solution = new Solution();
int[] number = {2,3,4};
int[] answer = {0,0,0};
int len = number.length;
solution.solution(len, number, answer);
}
}