public static void main(String[] args) {
// TODO Auto-generated method stub
char[] chs = new char[]{'a','b','c'};
Stack<Character> stack = new Stack<Character>();
for(int i = 1; i <= chs.length; i++){
combine(chs, 0, i, stack);
疑问就是在打印出【a】【b】【c】后. 然后在 forc循环中i=2的时候往函数combine传递参数的时候
打印出begin=1
1
[a, b]2
2
到这里了为什么begin=1和number=1而不是
begin=0和number=2???????????????????????????
begin1=1v1
1
begin=2
}
}
public static void combine(char []chs, int begin, int number, Stack<Character> stack){
System.out.println(1);
if(number == 1){
System.out.println("begin="+begin);
}
if(number == 2){
System.out.println("begin3333="+begin);
}
if(number == 0){
System.out.println(stack.toString()+begin);
return ;
}
if(begin == chs.length){
return;
}
stack.push(chs[begin]);
combine(chs, begin + 1, number - 1, stack);
System.out.println(2);
System.out.println("begin1="+begin+"v"+number);
stack.pop();
combine(chs, begin + 1, number, stack);
}
|