import java.io.*;
public class Test1 {
public static void main(String[] args) {
select(2);
}
private static void select(int k) {
char[] result = new char[k];
subselect(0, 1, result, k);
}
private static void subselect(int head, int index, char[] r, int k) {
for (int i = head; i < a.length + index - k; i++) {
if (index < k) {
r[index - 1] = a;
System.out.println("i="+(i)+";index="+(index));
subselect(i + 1, index + 1, r, k);
}
else if (index == k) {
r[index - 1] = a;
System.out.println(";i="+(i)+";index="+(index)+";index==k:"+(index==k));
System.out.print(i+"===");
System.out.println(r);
subselect(i + 1, index + 1, r, k);
} else {
System.out.println("++");
return;
}
}
}
private static char[] a = { 'a', 'b', 'c' };
} // 我收藏的代码 比较难以理解 你看着吸收吧 呵呵
|