作者在 2010-12-10 13:29:51 发布以下内容
public class TestTree {
/**
* @param args
*/
private int count = 0;
private int b[];
private boolean isFirst = true;
public static void main(String[] args) {
// TODO Auto-generated method stub
int a[] = {35,14,32,12,47,45};
TestTree t = new TestTree();
t.b = new int[a.length];
t.outData(a,0);
}
public static int c21(int x) {
return x*2+1;
}
public void outData(int a[], int index){
if(isFirst){
System.out.print(a[index]);
isFirst = false;
}
else{
System.out.print(","+a[index] );
}
int p = c21(index);
b[count++] = a[index];
if(p < a.length)
outData(a, p);
if(2*index+2 < a.length)
outData(a,2*index+2);
}
想让各位帮我解说一下这个程序,这是我老师给的样例,不过小弟不才,没能看懂,所以希望各位能帮帮我,谢谢啊,可以发我邮箱里:shangdongguoqiang@163.com