标准答案
2026-09-22 20:36:19
发布于:江苏
0阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5;
int n,a[maxn];
void dfs(int x)
{
cout << a[x] << " ";
if(2 * x <= n) dfs(2 * x);
if(2 * x + 1 <= n) dfs(2 * x + 1);
}
int main()
{
cin >> n;
for(int i = 1;i <= n;i ++)
{
cin >> a[i];
}
dfs(1);
return 0;
}
这里空空如也







有帮助,赞一个