import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] node = new int[n+1];
node[0] = -1;
for(int i = 1; i<n+1; i++)
node[i] = in.nextInt();
in.close();
int depth = (int) (Math.log(n) / Math.log(2));
ArrayList<Integer> res = new ArrayList<Integer>();
int index = 1;
while(index<n+1)
{
res.add(node[index]);
index = 2*index;
}
index = index/2+1;
while(index<n+1)
{
res.add(node[index]);
index++;
}
index = (int)Math.pow(2, depth) - 1;
while(index>1)
{
res.add(node[index]);
index = (index-1)/2;
}
for(int a: res)
{
System.out.print(a);
System.out.print(" ");
}
}
}
第一题如上,为什么通过为0
全部评论
(0) 回帖